Ask coding questions

← Back to all posts
JavaScript exercise test fail
KK998 (1)

Hello everyone!

While I have been going through the JavaScript exercises I encountered a weird test that for some reason fails my code.

I tested my code with some console.logs and conditionals and my code appear to be working.

Can someone take a peek at the repl and tells me if I'm doing something wrong or the test is faulty.

If the test is faulty where can I submit this bug so it can be fixed?
Cheers!

Answered by heyitsmarcus (288) [earned 5 cycles]
View Answer
Commentshotnewtop
heyitsmarcus (288)

Hey @KK998,

While your solution is correct for most cases, it won't satisfy all cases. For example, let's say I log this:

console.log("smallest word: ", findShortestOfThreeWords('asdfg', 'yes', 'yes'));

The output to the above is undefined since the length of words 2 and 3 match, and there is no programming to satisfy this condition.

You could add a few more if conditionals in there, and that would probably satisfy this challenge. But, also, think about different, more dynamic ways of doing this.

Good luck and happy coding!

heyitsmarcus (288)

@KK998 You're welcome! Happy Coding! =]

KK998 (1)

@heyitsmarcus Fixed my code and made it a bit more dynamic... sometimes I really a bit dumb =P

heyitsmarcus (288)

@KK998 Never, ever say that and be serious! It's not stupidity at all. The fact that you have got this far is something to be proud of!

KK998 (1)

@heyitsmarcus I meant hard headed. Focusing only on one thing not as in stupidity :D but thank you for encouragement and kind words!

heyitsmarcus (288)

@KK998 Well hey if I helped you out with your problem, please consider marking my answer as the accepted answer to close this question out. If you have any more questions, don't hesitate to come back and ask :)