Question
*ALL IN JAVASCRIPT Your code should always include descriptive comments. 1. Write a JavaScript for loop that will iterate from 0 to 15. For each
*ALL IN JAVASCRIPT
Your code should always include descriptive comments.
1. Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it will check if the current number is odd or even, and display a message to the screen.
Sample Output : "0 is even" "1 is odd" "2 is even"
2. Write a JavaScript function to get the first element of an array. Passing a parameter 'n' will return the first 'n' elements of the array. Test Data : console.log(first([7, 9, 0, -2])); console.log(first([],3)); console.log(first([7, 9, 0, -2],3)); console.log(first([7, 9, 0, -2],6)); console.log(first([7, 9, 0, -2],-3));
Expected Output : 7 [] [7, 9, 0] [7, 9, 0, -2] []
3. Create an object to hold information on your favorite recipe. It should have properties for title, servings, and ingredients (an array of strings). On separate lines (one console.log statement for each), log the recipe information so it looks like below. Use your own recipe. Creativity matters!
Cake
Serves: 2
Ingredients:
cinnamon
flour
sugar
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