Window of the input value is not the same as the results of 2 and 4 why?
Please everyone a great god,


CodePudding user response:
Because the prompt () is the content of the input string,Two strings with the + operation is the joining together of the string,
Such as "2" + "3" is equal to "23"
You need to use parseInt () or parseFloat () converts a string into value, and then to numerical computation,
Such as
X=parseFloat (prompt (" please input the value of x "));
CodePudding user response:
Thank you bosses took a long time didn't understand understand now