+ 1

How do you calculate a string?

For example: Var equation = "30+54"; Var answer = equation; Equation = 30+54 Answer = 84

21st Sep 2022, 9:00 AM
Yeeter
Yeeter - avatar
11 Answers
+ 5
console.log(+"30"+(+"54")) //😉
21st Sep 2022, 10:55 AM
Solo
Solo - avatar
21st Sep 2022, 9:30 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 5
you can use eval function 😁
21st Sep 2022, 5:16 PM
NinjaGamer
NinjaGamer - avatar
+ 3
Console.ReadLine() by itself wont work, as you need the value to be an integer. This is where our old friend Convert.ToInt32 comes in. This allows us to take the integer values out of the input and use it as a variable. var Q = Console.ReadLine(Convert.ToInt32); Console.WriteLine(Q);
21st Sep 2022, 10:23 PM
Tristan Smith
Tristan Smith - avatar
+ 3
You can also use: console.log(Number("5")+Number("5"))
22nd Sep 2022, 5:35 PM
NinjaGamer
NinjaGamer - avatar
+ 2
NinjaGamer64, initially the question was: "30"+"54" 🤔 But in this case: "30+54" - of course eval()
21st Sep 2022, 9:55 PM
Solo
Solo - avatar
+ 1
from your needs I suppose you need to try the eval() function... A sample Javascript code is given below var num1 = "123 + 456"; var sum = eval(num1); console.log(sum) Terminal: ____________________________________ 579
22nd Sep 2022, 7:57 AM
CoderBittu
CoderBittu - avatar
0
Use eval.
22nd Sep 2022, 7:05 PM
Abhimanyu
0
var equation = "30+54" var answer = eval(equation); console.log(answer);
23rd Sep 2022, 2:56 AM
⛈️𝕾𝖚𝖒𝖆 𝕭𝖆𝖘𝖆𝖐❄️
⛈️𝕾𝖚𝖒𝖆 𝕭𝖆𝖘𝖆𝖐❄️ - avatar
0
Reenasky it should automatically increment the numbers
23rd Sep 2022, 4:09 PM
Tristan Smith
Tristan Smith - avatar