Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function power_of2(num)
- {
- var array=[];
- for(var index =1; index<20 ; index++)
- {
- array.push(Math.pow(2,index));
- }
- for(var index1 =0 ;index1<array.length; index1 ++)
- {
- if(array[index1] === num)
- { return "true" ;}
- }
- return "false";
- }
- console.log(power_of2(4));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement