0
dynamically declare values // javascript
My problem is: I need to pass a number to my code. I would like to do it with alert. It does not work. I am completely frustrated since I do only have this problem (with syntax of course) in javascript. How to make it work? Thanks
6 Respostas
+ 3
alert() function only output message to user...
To get an input from user you should use prompt():
var input = prompt('enter some string value:");
+ 2
It should...
Provide your code to get more help ^^
+ 2
The problem is that you declare 'num' variable inside the number() function, so it does only exist in the local scope ^^
0
It does not work. I mean the value is not passed to the variable...
0
function number(){
var num=prompt("Give any number: ");
}
var x=0;
var y=0;
number();
x=num;
y = x+2;
0
Thanks! I see it. It now works! :)