Skip to content

smallestPowerOfTwo(), takes in an array and should return an array with the power of two which is greater than the value of each number element in the array provided as argument. For example, [5, 3, 9, 30] should return [ 8, 4, 16, 32 ].

Notifications You must be signed in to change notification settings

candytale55/smallest-Power-Of-Two_JS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

smallest-Power-Of-Two_JS

smallestPowerOfTwo(), takes in an array and should return an array with the power of two which is greater than the value of each number element in the array provided as argument. For example, [5, 3, 9, 30] should return [ 8, 4, 16, 32 ].

The purpose of the project is just learning and practicing.

How it works?

The function creates a new array, loop through the argument array and push in the smallest power of two which is greater than the current element.

The 'outer' for loop - loops through each element in the array.

The 'inner' while loop - searches for smallest power of 2 greater than the given number

To-do list:

  • Try doing the same using built-in methods.

Technologies

  • Javascript ES6

Setup

NA - It's only coding examples, there's no setup.

Status

Project is: finished, technically- may come back and improve it later.

References

Based on Codecademy's Web Development path courses, Code Challenges: Intermediate JavaScript exercises

About

smallestPowerOfTwo(), takes in an array and should return an array with the power of two which is greater than the value of each number element in the array provided as argument. For example, [5, 3, 9, 30] should return [ 8, 4, 16, 32 ].

Topics

Resources

Stars

Watchers

Forks