Instructor solution
You may exit out of this review and return later without penalty.
preworkAssessment.js Review Assignment
1.Declare a variable called animal and give it a value of your choice
2.Declare a variable called 'flavors' that is an array of 3 ice cream flavors.
3.Update the second element of the array flavors to be a different value, newFlavor (user input).
4.Add 2 more items, newFlavor1 and newFlavor2 (both user input), to the array flavors.
5.Make an object called pet that contains 2 properties:
- animal: Representing what type of animal the pet is.
- age: Representing the age of the animal.
6.Print the age property of the pet object.
7.Update the property age of the object pet to be newAge (user input).
8.Explain what each of the following datatypes are in JavaScript:
- String
- Number
- Boolean
- Array
- Object
9.Write a conditional that does the following:
js<br>// If the value of animal is "lion", print to the console "I'm scared!"<br>// If the value of animal is "dog", print to the console "So cute"<br>// If the value of animal is "frog", print to the console "Ribbit ribbit"<br>// For any other value, print "Just another animal"<br>
10.Write a conditional that does the following:
js<br>// If both ages, person1Age and person2Age, are less than 18, print "You are both children"<br>// Otherwise, print "At least one adult here" <br>
11.Write a for loop that prints the integers starting at 20, and counts down to 10. (Include 20 and 10)
12.Write a while loop that prints the multiples of 5 from 5 to 50 inclusive. (i.e. 5, 10, 15, 20 ...)
13.Write a function called multiply that takes in 3 numbers, and returns the product of the 3 numbers multiplied together.
14.Write a function that takes in an integer and prints all integers from 1 to that number. Next to each one it should print whether it is even or odd.
15.Write a function that takes in a string and returns the number of times the character a appears in the string.
16.Write a function that takes a string and returns which character appears the most times in the string.
You may exit out of this review and return later without penalty.