Linked Questions
31 questions linked to/from How to get numeric value from a prompt box?
2573 votes
32 answers
2.8m views
How can I convert a string to an integer in JavaScript?
How do I convert a string to an integer in JavaScript?
1 vote
2 answers
2k views
Why does Number.isInteger() return false even when I prompt in integer values? [duplicate]
do { var y = prompt("Enter a positive integer from 1 to 26"); var int = Number.isInteger(y); var x = parseInt(y); window.alert(int); } while (x > 26 || x < 1 || int == ...
0 votes
5 answers
2k views
specify the variable type in the prompt [duplicate]
Instead of the number addition this code is doing the string concatation. How to specify the type of the input in the prompt field(eg:number,string). var jonage = prompt("enter the johns age"); var ...
0 votes
1 answer
2k views
What is the best way to make a prompt into an integer in JS? [duplicate]
I am writing a program to perform "Russian Math" (using the numberphile youtube video on it as my basis for the algorithm). It works. But, to "prove" that it works, I'm giving the user the ability to ...
1 vote
5 answers
173 views
Javascript: Why won't my values equal up? [duplicate]
var check = true; var number = Math.floor(Math.random() * 20); while (check === true){ var guess = prompt("I picked a number 0 to 20, try to guess it!"); if (number === guess) { print("You ...
-1 votes
2 answers
405 views
How can i take n number of input in an array in javascript, python [duplicate]
I want to take an user input that determins the number of inputs desired to take & input that number of inputs . For example if i need to enter 5 inputs ,the user would get a prompt asking what ...
0 votes
1 answer
328 views
Why does the while loop stop with a string, but not with an integer? [duplicate]
I spent a lot of time searching and debugging, but I just can't figure out why does the while loop stop upon "guessing", when my variable is a string... const myName = 'Daniel'; let guess = ...
-1 votes
2 answers
182 views
JavaScript sum of numbers in an array producing string instead of numbers [duplicate]
The code below is outputting a string of numbers instead of the sum of the numbers in the array. For example, if n is set to 3 and the numbers 1 2 3 are added to the array the output is 0123 when I ...
-1 votes
1 answer
297 views
Convert a string to a number in console.log [duplicate]
I want the use to input the users age and send it to a new variable that adds + 10 to the age and write it outin the console.log. let age = prompt("Whats youre age ?") age1= age + 10; ...
3 votes
2 answers
187 views
How do I properly use prompts with if statements when creating a dialogue tree? [duplicate]
I am attempting to create a basic word game with a branching answer system. I am running into an issue right off the bat concerning prompts. When I write my 'if' statement to bring about another ...
0 votes
1 answer
75 views
Counter variable in for/loop. Why does one program work and the other fails? [duplicate]
So, in writing a program - in javascript - that sums numbers from 1 to N (number given by user), I have written a working program, but I am still confused as to why one proposed solution that I wrote ...
0 votes
2 answers
53 views
Average calculator finding strange and incorrect numbers [duplicate]
I am trying to make an average calculator. This is my code for it: var data = []; var yesno = confirm("Would you like to add more data?"); while (yesno) { var newdata = prompt("Enter a piece of ...
0 votes
1 answer
83 views
Why does this if statement not recognise numbers? [duplicate]
This code works fine on letters, returning if the letters are upper or lower case but it always returns the number as "6 is a uppercaseletter" let userLetter = prompt("Please enter an ...
0 votes
1 answer
79 views
I have a problem with the '+=' operator in NodeJs: when I add a number variable to an another number variable it combine them together [duplicate]
const ricarica = (conto, deposito) => { deposito = prompt("Quanti soldi vuole depositare sul suo conto? "); conto += deposito; return console.log(`Ora il suo conto ha una ...
2 votes
0 answers
83 views
Problem calculating the sum of arithmetic progression when using prompt() [duplicate]
I am trying this code to add a number starting from 1 to n using this mathematical equation:n = n(n+1) /2 var n = prompt("enter a number"); function adding(n) { let N = n * (n + 1) / 2; ...