r/javascript • • Feb 20 '17

Learn JavaScript With Interactive Challenges: Earn XP, Unlock Achievements & Climb The Leaderboard

https://edabit.com/explore
125 Upvotes

17 comments sorted by

View all comments

0

u/[deleted] Feb 23 '17

This website has bugs and thus not reliable.

Example:

Challange

Replace Letters With Position In Alphabet

Solution

function alphabetIndex(str) {
  return str.toLowerCase().split('').map((x) => {
    if (/[a-z]/.test(x)) {
      return x.charCodeAt(0) - 96;
    }
  }).join(' ').trim();
}

Tests (Failed)

Expected: '3 8 5 3 11 2 1 3 11 20 15 13 15 18 18 15 23 9 23 9 12 12 19 5 5 9 6 20 8 5 2 15 15 11 8 1 19 1 18 18 9 22 5 4', instead got: '3 8 5 3 11 2 1 3 11 20 15 13 15 18 18 15 23 9 23 9 12 12 19 5 5 9 6 20 8 5 2 15 15 11 8 1 19 1 18 18 9 22 5 4'

Proof (Gives true)

"3 8 5 3 11 2 1 3 11 20 15 13 15 18 18 15 23 9 23 9 12 12 19 5 5 9 6 20 8 5 2 15 15 11 8 1 19 1 18 18 9 22 5 4" === "3 8 5 3 11 2 1 3 11 20 15 13 15 18 18 15 23 9 23 9 12 12 19 5 5 9 6 20 8 5 2 15 15 11 8 1 19 1 18 18 9 22 5 4" // true