1) How to calculate the multiplier
Question 1: To the power of 3 (I can't fight, please forgive me ==!!!)
To the power of 3 = 3*3*3*3var a = Math.pow(3,4);console.log(a);
Description: Math.pow() is a syntax used to calculate multiplier
Note: Math's M is capitalized;
Question 2: 4*5th power of 3
var a =Math.pow(3,4*5); console.log(a);
2) How to calculate the root number
Title: Root number 81
var a = Math.sqrt(81); console.log(a);
Variable format conversion
User input
var year = prompt("Brother, when did you come from~");var age = 2016-year;console.log("Wow, brother, you are "+age+" years old!");Note: prompt can wait until the user outputs content and calculate it
Note: The content addition of propt is the default string type
Use of parseInt
Convert string to number
Li Yi: var a ="100"; var b =parseInt(a);//Convert the string "100" in a to 100 console.log(b);//Output the number 100 console.log(typeof b);//Number type
Li Er: var a ="I can't say a sentence well, brother, are you stupid?"; console.log(parseInt(a));
Round
For example: output 3.1415926var a =3.1415926;console.log(parseInt(a));
Description: parseInt can convert strings to numeric types, and can also be used to round numbers.
Note: rounding will not be rounded
Summarize
The above is the complete content about operator multiplication, square making and variable format conversion in JS. I hope this article will be helpful to everyone to learn Javascript.