Last active
March 21, 2019 17:28
-
-
Save kylelong/c6c4d317bb768a40793f998940d23ab6 to your computer and use it in GitHub Desktop.
Cassido's newsletter interview question of the week 3/18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let nums = [] | |
function squareCubeNums(num){ | |
for(var i = 1; i <= num; i++){nums[i] = i;} | |
//Check for perfect square && check for perfect cube | |
nums = nums.filter(number => Math.floor(Math.sqrt(number)) - Math.sqrt(number) == 0 && Math.pow(Math.round(Math.pow(number, 1/3)), 3) == number); | |
console.log(nums); | |
} | |
squareCubeNums(64); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment