Question

In: Computer Science

Javascript: Create a loop that counts from 1 to 20. // If the current number is...

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

Solutions

Expert Solution

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.


Related Solutions

-create a magic 8 ball program in JavaScript - use a loop to ask for the...
-create a magic 8 ball program in JavaScript - use a loop to ask for the question - use a random number to get the answer let randAnswer=Math.round(Math.round()*10); - must have at least 10 different answers -Must use either elseif or switch statement for answer -must output both answer and user input to console - the program should repeat indefinitely until either blank input, or cancel is selected Bug in jsbin.com Please don't use HTML thanks
-create a magic 8 ball program in Javascript. -use a loop to ask for the question...
-create a magic 8 ball program in Javascript. -use a loop to ask for the question -use a random number to get the answer let randAnswer = Math.round(Math.random()*10); -must have at least10 different answers -must use elseif or switch statement -must outputs both answers and user to input the console -program should repeat indefinitely until either blank input or cancel is selected
Write a RIMS-compatible C-language for-loop that counts the number of times a bit of A is...
Write a RIMS-compatible C-language for-loop that counts the number of times a bit of A is followed by a bit of the opposite parity (01 or 10) and writes the value to B. For example 00100110 has 4 cases: 00100110, 00100110, 00100110, 00100110.
Create a program in C that counts the number of characters in a word when a...
Create a program in C that counts the number of characters in a word when a user inputs a string. Use stdin to read an input string. For example, if a user inputs: “The dog is good” the output should be a= [The], b=3 a= [dog], b=3 a= [ is], b=2 a= [good], b=4 a= [ ], b=0000 Take into account EOF. If an EOF is reached at the end of the string then the output should be 0000. (example...
Create a program in C that counts the number of characters in a word when a...
Create a program in C that counts the number of characters in a word when a user inputs a string. Use stdin to read an input string. For example, if a user inputs: “The dog is good” the output should be a= [The], b=3 a= [dog], b=3 a= [ is], b=2 a= [good], b=4 a= [ ], b=0000 Take into account EOF. If an EOF is reached at the end of the string then the output should be 0000. (example...
Create a JavaScript function that will collect the information from the form and verify that it...
Create a JavaScript function that will collect the information from the form and verify that it is the correct type and that there are no blank textboxes. Save and test the file to ensure that the textbox information is collected and the script is working correctly. Use the onclick event within the submit button to call this function. Output validation error messages by writing directly to the with the id of "results." (You may want to use alert boxes for...
Please Use JavaScript and HTML 5) Number guesser (easier) Create a number guessing name, using an...
Please Use JavaScript and HTML 5) Number guesser (easier) Create a number guessing name, using an input and a button to gather a number. The number to be guessed should be a hard-coded whole number between 1 and 20. Tell the user if the number is too high, equal to, or too low than a number you have hard-coded in your application. Remove the text in the input when the user clicks the button.
Write a function that counts the colors in a string using JavaScript. String "The quick brown...
Write a function that counts the colors in a string using JavaScript. String "The quick brown fox jumped the blue fence and landed on red paint." This should return the number of colors. The colors you are looking for are "blue, green, brown, gray, black, brown, red, purple".
in C a program that counts up from 0 to 20, and reset to 0 after...
in C a program that counts up from 0 to 20, and reset to 0 after 20. needs to count by a press button
The code to create a Search/Filter Data with Javascript or html from html page.
The code to create a Search/Filter Data with Javascript or html from html page.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT