Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago