What is analog a prompt. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is analog a prompt.

We have to get a number isn't a string. user enter something in browser,function cheak this. If it's a number, function add num in array. I need analog prompt becouse he return string. If +"a" will number it's not suitable.

7th Jul 2018, 5:41 PM
Даниил Елин
Даниил Елин - avatar
5 Answers
+ 6
let numb = +prompt("Enter a number, please"); console.log(numb); // "number" Nope?
7th Jul 2018, 5:49 PM
\__(° = °)__/
+ 4
Here is the lesson about prompt: https://www.sololearn.com/learn/JavaScript/1149/?ref=app Also, you can convert the string received to a number like this: let number = parseInt(prompt('Enter a number'));
7th Jul 2018, 5:51 PM
giannismach
giannismach - avatar
+ 2
Please describe your question in more detail so that somebody can help you.
7th Jul 2018, 5:47 PM
giannismach
giannismach - avatar
0
user enter something in browser,function cheak this. If it's a number, function add num in array
7th Jul 2018, 5:49 PM
Даниил Елин
Даниил Елин - avatar
0
var arr = []; var n = parseFloat(prompt("Please, enter a number"); if(n!=NaN) arr.push(n); else alert("This is not a number");
7th Jul 2018, 7:14 PM
Дмитро Іванов
Дмитро Іванов - avatar