In: Computer Science
Javascript:
Create a loop that counts from 1 to 20. // If the current number is even, add it to this empty array: var myArray = []; // If the current number is odd, log an odd number warning to // the console. // However, if the number equals 19, set a debug breakpoint. // After the loop completes, print the array to the console.
var myArray = []; for (var i = 1; i <= 20; i++) { if (i % 2 === 1) { console.warn("odd number"); } else { myArray.push(i); } if (i === 19) { console.debug(); } } console.log(myArray);
The code is not printing to my screen. help please
There is nothing wrong with your code.In order to see your output you need to go for console page in web browser.Because your printing the output in console.
Press F12 and go for console window.There you can find your output as shown in the picture.
note:-recommended chrome
Thank you.