Can anyone someone help me why MULTIPLICATION and DIVISION button isn't working? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 10

Can anyone someone help me why MULTIPLICATION and DIVISION button isn't working?

I've made my own calculator. Two buttons are working but the other aren't. Maybe only 2 buttons can be use in HTML? https://code.sololearn.com/WWa0NMXKlIM5/?ref=app

7th Jun 2017, 4:45 AM
¤ rookie ¤
¤ rookie ¤ - avatar
10 Answers
+ 1
You mistyped the HTML on these buttons. (note the onclcik)
7th Jun 2017, 4:47 AM
Igoor Silver
Igoor Silver - avatar
+ 9
@Tiyam ah I see. Thanks for the info. I'm still learning JS 😂
7th Jun 2017, 7:49 AM
¤ rookie ¤
¤ rookie ¤ - avatar
+ 8
wow thanks a lot @Tiyam Foyraz HAHAHA lol I'm also looking for solution about that. Thank you! but what does parseInt() means? And also why in the other Operation it is okay withouth parseInt() i mean like in the Division, Multiplication, Subtraction they are working fine.
7th Jun 2017, 6:49 AM
¤ rookie ¤
¤ rookie ¤ - avatar
+ 7
@StoffelJs i've already tried it. even if it has semicolon or not. it is still working. the thing I'm in trouble is the multiplication and division button isn't working.
7th Jun 2017, 4:51 AM
¤ rookie ¤
¤ rookie ¤ - avatar
+ 7
@Igoor Silver thank you buddy! I never saw the "onclik" I mistyped it.
7th Jun 2017, 4:54 AM
¤ rookie ¤
¤ rookie ¤ - avatar
+ 7
By the way thank you guys for the help.
7th Jun 2017, 4:55 AM
¤ rookie ¤
¤ rookie ¤ - avatar
+ 6
@rookie have you checked doing addition on your code..I just modified your code and fixed a bug!! adding two numbers in your code results in string concatenation..example:- adding 10 with 10,results in 1010.. to avoid javascript string concatenation,use the code I used in the addSum() function. what happened?--In your addsum() function, I entered your prompt inputs inside a parseInt() function,which converts your prompt inputs from string to integer.Now,if you add them,it will result in a numerical addition rather than a string concatenation. https://code.sololearn.com/W4Z80qsOGrcj/?ref=app
7th Jun 2017, 6:25 AM
ElricTheCoder
ElricTheCoder - avatar
+ 6
Answering your 1st part - parseInt() is basically a javascript built-in function that is used to parse your strings into integer value.. to learn more,check this link- https://www.w3schools.com/jsref/jsref_parseint.asp Your second part - JavaScript string concatenation happens only when you use + sign.. so,when you use minus(-),division(/),or multiplication(*),the browser considers your input strings as numerical values and completes the operation. NOTE- if your input was a string,like "I am rookie",and you use "I am rookie"*5,then the result would have been NaN(not a number)...Thats how javascript works.!
7th Jun 2017, 7:44 AM
ElricTheCoder
ElricTheCoder - avatar
+ 5
@rookie great!!.just keep learning.. don't stop.
7th Jun 2017, 7:57 AM
ElricTheCoder
ElricTheCoder - avatar
+ 1
You dont need a ; in Html its not onclick="subNumb();" it should be onclick="subNum()"
7th Jun 2017, 4:47 AM
StoffelJs