logo CodeStepByStep logo

print

Language/Type: JavaScript arrays

Write a function named print that accepts an array as a parameter and prints them, one per line, in the format shown. Your code should work for an array of any size. For example, if an array named a contains the elements [32, "foo", 27.5, "bar", true, -3, 2598], then the call of print(a) should produce the following output:

element [0] is 32
element [1] is foo
element [2] is 27.5
element [3] is bar
element [4] is true
element [5] is -3
element [6] is 2598

Use console.log() to output each line to the console.

Function: Write a JavaScript function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.