How to print exponential notation of a number in JavaScript

1 Answer

0 votes
const num = 847401
 
console.log(num.toExponential())
 
console.log(num.toExponential(1))
 
console.log(num.toExponential(2))
 
console.log(num.toExponential(3))
  
  
      
      
/*
run:
 
"8.47401e+5"
"8.5e+5"
"8.47e+5"
"8.474e+5"
      
*/

 



answered Aug 12, 2022 by avibootz
...