How to calculate the cube of a number in Node.js

1 Answer

0 votes
function cube(n) {
    return Math.pow(n, 3);
}
 
let n = cube(2);
console.log(n);
  
console.log(cube(3));
  
n = cube(4);
console.log(n);
  
 
            
  
/*
run:
    
8
27
64
      
*/

 



answered May 21, 2024 by avibootz
edited May 21, 2024 by avibootz

Related questions

1 answer 273 views
1 answer 235 views
1 answer 181 views
181 views asked Nov 16, 2022 by avibootz
1 answer 225 views
2 answers 329 views
...