#Elyses Enchantments JS

25 messages · Page 1 of 1 (latest)

raven marten
#

Hey, I don't get why my code isn't working, can someone help me?

Here's what I have to do and the error

Here's my code

  const lenght = cards.length
  if (length == stackSize) {
    return (true)
  } else {
    return (false)
  }
}```
pseudo sentinel
#

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?

raven marten
#

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?

pseudo sentinel
#

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.

pseudo sentinel
#

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?

raven marten
#

to be honest with you man, I dont know :(

#

I think my problem is interpretation

pseudo sentinel
#

I’m asking about the code you shared. At some point, the code returns true. Where is it?

raven marten
#

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

raven marten
pseudo sentinel
#

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.

raven marten
#

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

pseudo sentinel
#

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.

undone rover
#

Spelling is very important when telling computers what to do. They do exactly what you tell them, typos and all.

raven marten
#

but thank you man

pseudo sentinel
#

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.

buoyant glenBOT
#

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!