1. Declare a variable named num with an
initial value of 0. Create a while loop that
will print "Keep going" as long as the value
of num is less than 5. Use window.alert()
for displaying the output.
2. Create a function named showProd that
returns the product of n1 and n2.
3. Using the new keyword, create an array
named info with three (3) values: your first
name, your nickname, and your last name.

Respuesta :

The code to

  • Declare a variable and increment with a while loop until the variable is not less than 5
  • Create a function that returns the product of two numbers
  • Uses the new keyword to create an array

were written in JavaScript and are found in the attached images

Declaring a variable

The first code declares a variable called num and gives it an initial value of 0. It then enters a while loop that lauches a message box (using window.alert) to print the message "Keep going" as long as num remains less than 5.

If nothing is done within the loop to increment num towards the value 5, the loop will go on endlessly notifying the user to "Keep going".

So, an increment of 1 was added to the loop body to increment the variable num. This makes sure the loop terminates.

Creating a function that returns the product of two numbers

Here, a function was created that receives two arguments (n1  and n2), then returns the product (n1 * n2)

Declaring an Array

This last code segment creates an array using the new keyword. The new keyword is generally used in constructing objects.

In this case the object constructed is an array having three strings;

  • my first name
  • my nickname, and
  • my last name

See another solved JavaScript problem here https://brainly.com/question/23610566

Ver imagen batolisis
Ver imagen batolisis
Ver imagen batolisis