JakAttack909 / blockly

Automatically exported from code.google.com/p/blockly
0 stars 0 forks source link

wrong value given by simple addition when done by reading the values #95

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.prompt blockly to read two numerical values
2.set a third variable as thier sum
3.now try to print the sum

What is the expected output? What do you see instead?

suppose i put the two values to be 3 and 4 so the excted output is 7 but 
instead the result comes out to be 34 ie 10x+y instead of x+y

What browser are you using?
GOOGLE CHROME

Please provide any additional information below.
here is the corresponding javascript
var x;
var y;
var z;

x = window.prompt('x');
y = window.prompt('y');
z = x + y;
window.alert(z);

Original issue reported on code.google.com by dwipaya...@gmail.com on 16 Dec 2012 at 5:41

GoogleCodeExporter commented 8 years ago
In JS, 3 + 4 = 7 but '3' + '4' = '34' as a string.
The prompt block allows both text and number. You just have to click into the 
field "text" to see the drop down with an option for "number" instead.  
See this example:
http://blockly-demo.appspot.com/static/demos/code/en.html#84urto
(Whether or not we should make the dropdown more obvious is a design question, 
with both pros and cons, which may be revisited.)

Original comment by Q.Neut...@gmail.com on 17 Dec 2012 at 2:20

GoogleCodeExporter commented 8 years ago
thanx..:)..now it seems to me to be a silly question..:P

Original comment by dwipaya...@gmail.com on 17 Dec 2012 at 5:05