How to get the length of a Number in JavaScript?
Answers
Answered by
0
Answer:
Use the toString() method to covert the Number to string, then the length() method gives you length. You can try to run the following code to learn how to get the length of a Number:
Example
Live Demo
<!DOCTYPE html>
<html>
<body>
<script>
var num1 = 344;
var num2 = 149856;
document.write("Length of number "+num1+" = "+ num1.toString().length);
document.write("<br>Length of number "+num2+" = "+ num2.toString().length);
</script>
</body>
</html>
Output
Length of number 344 = 3
Length of number 149856 = 6
HOPE THIS WILL HELP U. IF THIS HELPS U THEN PLS MARK THIS AS BRAINLIEST..
Similar questions