Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define the following functions in the console ornode -i : function junk1() { for(i1=1; i1

Define the following functions in the console ornode -i :

function junk1() {

for(i1=1; i1<=2; i1++){console.log(i1);}

return `i1 is ${i1}`;

}

function junk2() {

for(var i2=1; i2<=2; i2++){console.log(i2);}

return `i2 is ${i2}`;

}

function junk3() {

for(let i3=1; i3<=2; i3++){console.log(i3);}

return `i3 is ${i3}`;

}

a. Executejunk1() theni1 explain whyi1 is defined outside the function.

varretString =junk1();

console.log("Junk1=" +retString);

console.log("i1=" +i1);

b. Executejunk2() theni2 explain why you getUncaught ReferenceError: i2 is not defined when you try to usei2 outside the function.

c. Executejunk3() theni3 explain why you getUncaught ReferenceError: i3 is not defined for each of these and why the return valuei3 is 3 does not appear as it does for the previous examples (that is, you cannot usei3 outside the function or outside the for-loop).

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Summarize the ABCDE method for overcoming irrational beliefs.

Answered: 1 week ago