I've been stuck on this for a while. I used excel to visualize the final result, but I am just not understanding how to implement the "if case"

to deduct 1 on the subsequent loops.

Here is the question...

It's Easter Sunday and it's showtime for the Easter Bunny. He has 100 baskets to fill. He goes through each basket and puts an egg in. Then he goes back to the beginning. He stops at every second basket and if the basket has an egg in it (all of them do, in this case), he takes the egg out. Otherwise he puts an egg in. Then he goes back to the beginning. He stops at every third basket, taking an egg out if there's an egg or putting an egg in if there isn't. He does this for every fourth basket, fifth basket, etc., all the way up to every hundredth basket. Once he's finished, which baskets have eggs in them? Write the code to solve this question.

Here is my code so far.., step 1, no problem, subsequent loops... no success so far.

I believe that on the inner loop a multiple of i * j, will specify which basket to deduct from. I have not been able to succeed so far with various attempts.

to deduct 1 on the subsequent loops.

Here is the question...

It's Easter Sunday and it's showtime for the Easter Bunny. He has 100 baskets to fill. He goes through each basket and puts an egg in. Then he goes back to the beginning. He stops at every second basket and if the basket has an egg in it (all of them do, in this case), he takes the egg out. Otherwise he puts an egg in. Then he goes back to the beginning. He stops at every third basket, taking an egg out if there's an egg or putting an egg in if there isn't. He does this for every fourth basket, fifth basket, etc., all the way up to every hundredth basket. Once he's finished, which baskets have eggs in them? Write the code to solve this question.

Here is my code so far.., step 1, no problem, subsequent loops... no success so far.

Code:

function easter(num){ var basket = {}; for(var i = 1; i <=num; i++){ for(var j = 1; j <= num; j++){ if(!basket[j]){ basket[j] = 1; }else{ basket[j] += 1; } } } return basket; }

## Comment