I was wondering if i could get the answers and code for these questions 1. Given
ID: 3730424 • Letter: I
Question
I was wondering if i could get the answers and code for these questions
1. Given the following code, write statements that will assign the values requested:
Create a variable named adding that uses elements in the numbers array such that adding = 19.
Create a variable named divide that uses elements in the numbers array such that divide = 9.
2. Write JavaScript code to create an array named usernames[] that has 100 elements. Each element contains usernames for a school that assigns usernames to students. Each username concatenates the string "college" with a number. The numbers should start at 300 and end at 399.
3. Given an array named items[] that holds the names of various items sold in a jewelry business. List three arrays that, as parallel arrays, will hold appropriate data to correspond with each item in items[] .
23 Given an array named snow[] that contains yearly snowfall amounts in inches in a certain area over a period of 10 years from 2000 to 2009. Use a loop to display these amounts. The output should be on 10 lines, each line of the following form:
where XXXX is the year and YY is the amount in inches.
Given: var snow = new Array(6, 8, 8, 12, 21, 15, 7, 8, 10, 15);
24 Add code to Exercise 23 to find and display the years with the highest and lowest snowfall amounts.
26 Add code to Exercise 25 to find the number of years that snowfall was above the average.
28 Add code to the addRings() function of Example 8.14 in the chapter to check if a value Jackie wants to add to her inventory is already part of the inventory.
30 Given the following JavaScript code, what are the values of the eight elements in the numbers[] array?
Explanation / Answer
<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<script>
function sayHello() {
var numbers = new Array(2, 3, 5, 7, 11);
var adding = numbers[1] + numbers[2]+numbers[4];
var divide = (numbers[3]+numbers[4])/numbers[0];
console.log("Add=",adding,"Divide=",divide);
var snow = new Array(6, 8, 8, 12, 21, 15, 7, 8, 10, 15);
var m=0,m1=0,max=6,min=6,avg,sum=0;
for(var i=1;i<snow.length;i++){
if(snow[i]>max){
max=snow[i];
m=i;
}
if(snow[i]<min){
min=snow[i];
m=i;
}1
sum+=snow[i];
}
avg=sum/10.0;
var c=0;
for(var i=0;i<snow.length;i++){
if(snow[i]>avg)c+=1;
console.log("Snowfall for the year ",2000+i," is ",snow[i]," inches")
}
console.log("Max=",2000+m,"Min=",2000+m1,"Above average=",c);
var numbers = new Array;
for(var i = 0; i < 8; i++)
numbers[i] = (i * i) + 1;
console.log("Numbers=",numbers);
}
sayHello();
</script>
</head>
<body>
</body>
</html>
30. Numbers= Array [ 1, 2, 5, 10, 17, 26, 37, 50 ]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.