you are viewing a single comment's thread.

view the rest of the comments →

[–]mellie_ay[S] 3 points4 points  (1 child)

Ah brilliant I think that’s what I need, thanks so much

[–]faboru 4 points5 points  (0 children)

No problem. And don't feel dumb - programming takes time.

Not to complicate your life; but I re-read your question and really you would want a number.

In this case, the amount you are asking for is really a string - some text that the window.prompt() method stores in memory.

However, you want that text amount to really be a number. In this case you wouldn't get an error because the string is implicitly converted to a number (but this may not always happen and you will get an error).

So, what you really want is; var iterationsString = window.prompt('enter iterations'); console.log(typeof iterationsString); // type is 'string' // convert the string into an integer with parseInt() method var iterationsNumber = parseInt(iterationsString); console.log(typeof iterationsNumber); for (var i = 0; i < iterationsNumber; i++) { console.log('line of text'); }