Calculating Powers in JavaScript, NodeJS

// Section 1 - 08 : Power of 2^24
// Using NodeJS

// Using internal function 'pow()'
console.log(`2^24 = ${Math.pow(2, 24)}`)

// As program
let x = 1
let counter = 0
do {
    x = x * 2
} while ( ++counter < 24 )
console.log(`f() = ${x}`) // 16777216
2 Likes

Nice looking code! :+1: