#Elyses Enchantments JS
25 messages · Page 1 of 1 (latest)
Alright, this is going to take a few steps. So, you’re returning a true instead of an expected false. Do you understand where and why you might be returning true?
to be honest, no
I didn't understand the "a stack with a single card has exactly 1 card", why is this popping up? wasn't fot me just to check if the number of cards were equal to the stack size?
That’s the human-readable name for a group of tests that assert something about your code. For a concept exercise, you can’t see the tests so that helps you understand what’s being checked. We’re checking here whether a stack with a single card returns the right true/false for different stack sizes.
yes, I got this
The failed test is expecting false. That means the passed stack size isn’t correct for the passed stack. So what part of your code could result in true being returned?
I’m asking about the code you shared. At some point, the code returns true. Where is it?
I just dont know why this "a stack with a single card has exactly 1 card" was tested if I just want to compare the stack size given to the real stack size
oh ok, it returns true if the length of the array 'cards' is equal to the stackSize
I’d suggest rereading the code closely. Are we sure that’s what length represents in this if statement? Computers take us very literally so we need to be careful with spelling.
man, I did this
look
if (cards.length == stackSize) {
return (true)
} else {
return (false)
}
}```
and it worked, when I tried it IN THE BEGGINING SOMEHOW it was not going
bro
my misspelling again 😭😭😭
can't believe I was stuck just bc of this
Yeah, it happens to us all. JavaScript can be pretty lenient with some errors and paper over them that other languages would stop and say there’s an issue.
Spelling is very important when telling computers what to do. They do exactly what you tell them, typos and all.
thank you for your patience with me friend. I'm brazillian and I was very sleppy at the moment I wrote the code, so it's a bit difficult for me
but thank you man
I’d recommend a code review session with a mentor on the site. We didn’t mention it here, but there’s some interesting knowledge to gain discussing why a typo in turn led to your weird result.
If everything is resolved, we ask that the person who posted the request react to the top/original post with a :white_check_mark: (:white_check_mark:). This indicates to others that this issue has been resolved and locks the thread.
If all the tests pass and you want to further improve your solution, we encourage you to use the "Request a Code Review" feature on the website!