Question
JavaScript Assignment 3 Create an array called ages that contains the following values:3, 9, 23, 64, 2, 8, 28, 93. Programmatically subtract the value of
JavaScript Assignment 3
Create an array called ages that contains the following values:3, 9, 23, 64, 2, 8, 28, 93.
Programmatically subtract the value of the first element in thearray from the value in the last element of the array (do not usenumbers to reference the last element, find it programmatically,ages[7] – ages[0] is not allowed). Print the result to theconsole.
Add a new age to your array and repeat the step above to ensureit is dynamic (works for arrays of different lengths).
Use a loop to iterate through the array and calculate theaverage age. Print the result to the console.
Create an array called names that contains the following values:‘Sam’, ‘Tommy’, ‘Tim’, ‘Sally’, ‘Buck’, ‘Bob’.
Use a loop to iterate through the array and calculate theaverage number of letters per name. Print the result to theconsole.
Use a loop to iterate through the array again and concatenateall the names together, separated by spaces, and print the resultto the console.
How do you access the last element of any array?
How do you access the first element of any array?
Create a new array called nameLengths. Write a loop to iterateover the previously created names array and add the length of eachname to the nameLengths array.
Write a loop to iterate over the nameLengths array and calculatethe sum of all the elements in the array. Print the result to theconsole.
Write a function that takes two parameters, word and n, asarguments and returns the word concatenated to itself n number oftimes. (i.e. if I pass in ‘Hello’ and 3, I would expect thefunction to return ‘HelloHelloHello’).
Write a function that takes two parameters, firstName andlastName, and returns a full name (the full name should be thefirst and the last name separated by a space).
Write a function that takes an array of numbers and returns trueif the sum of all the numbers in the array is greater than 100.
Write a function that takes an array of numbers and returns theaverage of all the elements in the array.
Write a function that takes two arrays of numbers and returnstrue if the average of the elements in the first array is greaterthan the average of the elements in the second array.
Write a function called willBuyDrink that takes a booleanisHotOutside, and a number moneyInPocket, and returns true if it ishot outside and if moneyInPocket is greater than 10.50.
Create a function of your own that solves a problem. Incomments, write what the function does and why you created it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started