Posts

Post not yet marked as solved
2 Replies
I have the same question too.Actually if you're going to use isOnGemwith turnLeft() and collectGem(), there is no exclamation mark (signifies "not"). This was my answer to the Nesting Loops exercise:While !isBlocked { While isOnGem { turnLeft() collectGem() } moveForward()}The result I got with this response is the character stopping on the 2nd gem, facing forward. It turns left and collects the gem at the 1st spot. Why doesn't it do the same thing with the later gems after that? I know While Loops are supposed to keep going but the character is stopping before finishing collecting all the gems.Maybe there is something wrong with my thinking? I don't know. I wrote this code so that the character keeps on the outer loop until it encounters the inner loop (gem). Once the inner loop is completed, doesn't it go back to following the outer loop again?Also, the supposed correct answer doesn't make sense to me:While !isBlocked { While !isOnGem { moveForward() } collectGem() turnLeft()}Since the way is not blocked for several tiles in the first row, is Byte (the character) supposed to be collecting gems and turning left at every single tile???