I want to ask the user via a prompt to Enter a number:. Then, I want to use an array to print the numbers to the screen like a "normal pyramid" and an "upside-down pyramid".
I want to make an input field and a button next to it. Inside the input side you can give a number between 1-20 when you click on the button it should show this:
But only till the number you put inside the field so if you put 8 the pyramid only show 1-8 and not 9-20.
var number = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
question();
function question() {
if(question != 1) {
prompt("enter a number.", "20");
for (var a = 0; a < question; a++) {
}
}
}
I tried doing this, but I can't get it to work.


forloop body is emptyquestion != 1for?questionis the name of the function right? And whats is the purpose of the arraynumberafter all If you want to get user's input? Also, I suggest you to check prompt() docs, you're using it wrong.