This will probably be my last one for a while, as I need to learn more in depth
What is your hint or solution suggestion?
How can you create an array of all squared numbers that is of a certain length? And how to filter out numbers for which x**(2/3)
is not an integer before they are added to the array? Use Math.cbrt
for a precise cube root.
Solution 1
function exponentialGenerator(n) {
var firstNumbers=[];
// Only change code below this line
var i = 2;
do {
if(!Number.isInteger(Math.cbrt(i**2))){
firstNumbers.push(i**2)
}
i++;
}
while (firstNumbers.length < n);
return firstNumbers[n-1];
}
Challenge: Generator/Exponential
Link to the challenge: