How to calculate the cube of a number in TypeScript

1 Answer

0 votes
function cube(n: number) {
    return Math.pow(n, 3);
}
 
let n: number = 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
...