r/webdev • • Feb 20 '17

Learn JavaScript With Interactive Challenges X-Post /r/JavaScript

https://edabit.com/explore
205 Upvotes

36 comments sorted by

View all comments

4

u/SteveB0X Feb 20 '17

I just want to say, this is a really great site. The challenges are very approachable for me, which is something I can't say about the hackerranks and leetcodes. It's exactly what I need right now.

However, I'm having trouble getting my first challenge to submit. My code is printing out the answers to the console, but the test is not accepting them. I.e.,

Duck
Expected: 'Duck', instead got: undefined
3
Expected: 3, instead got: undefined
undefined
Test Passed: Value == undefined
true
Expected: true, instead got: undefined
null
Expected: null, instead got: undefined    

Here is my solution (spoiler)

So to me, it seems like I have the correct code, but the interpreter is not seeing my answers. What is the correct way to print the output so it is accepted?

3

u/memystic Feb 20 '17

Works fine for me. Go to this challenge and paste this into the Code tab:

function getLastItem(arr) {
  return arr[arr.length - 1]
}

Click the "Check" button. Should work fine.

2

u/SteveB0X Feb 20 '17

Oh I get it now! I'm so used to console.log-ing everything, when all I needed to do was return my lastItem variable by itself.

Thanks!

2

u/memystic Feb 20 '17

No problem, if you have any other questions just PM me or email [email protected]