Question: javascript arrays Create an empty array called randomNumbers. Write a for loop that will add 4 random numbers to the randomNumbers array using Math.random() and

javascript arrays

Create an empty array called randomNumbers. Write a for loop that will add 4 random numbers to the randomNumbers array using Math.random() and push.

Create an array name foods and add 10 foods to it. Create another array called favoriteFoods but leave it empty. Create an array that loops through the foods array and adds the current item to the favoriteFoods array if the string is longer than 6 characters (i.e. string.length > 6).

conditionals

Create a variable and assign it a random number between 0 and 100 using Math.random(). Create a conditional so that if the number is greater than 50, you print the message "That's a big number!"

Monkey in the middle! Create a variable and assign it a random number between0 and 10 using Math.Random(). Create a conditional that:

- prints "small number" if the number is less than 5

- prints "big number" if the number is greater than 5

- otherwise, prints "monkey"

functions:

Write a function printLongestWord that accepts a single argument, an array of strings. The method should return the longest word in the array. In case of a tie, the method should return the word that appears first in the array.

i.e. printLongestWord(["BoJack", "Princess", "Diane", "a", "Max", "Peanutbutter", "big", "Todd"]); // => "Peanutbutter"

Create a function that takes a string as a parameter and returns the uppercase version of the string (using the toUpperCase) method.

Write a function that takes a sentence as a parameter and returns the words in the sentence in reverse order.

Write a function that takes a phone number (as a number) and returns a formatted string. So if the number 2025171777 is pass in, the string '(202) 517-1777' will be returned

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!