0
How do I add two numbers with a string and get an output
int x = Integer.parseInt("2"); int y = Integer.parseInt("3"); int z = x + y; //5 I tried this... but nothing shows up.
7 Answers
+ 2
Try this:
var x = parseInt("2" );
var y = parseInt("3");
var z = x+y;
console.log(z);
+ 1
You want to print that number in console or where? In a html file?
0
try this
var x= "3";
var y= "2";
x *= 1;
y *=1;
var z=x+y;
console.log(z);
0
Just trying to get an output. Haven't done anything with HTML file. I've done all of this with the code playground in app, and nothing is showing up. The page is just blank.
var x= ("3");
var y= ("2");
x *=1
y *=1
var z=x+y;
Console.log(z);
Is there any way to see error messages, etc here?
0
add
document.write(z);// after console.log
0
Mason S, please go check my profile, i did an example for you so you can better understand :D
- 1
Still didn't work...:/
var x= parseint("3");
var y= parseint("2");
var z=x+y;
console.log("z");