Build a Linked List - Step 5

Tell us what’s happening:

I’m getting an error saying “5. You should log isEmpty(myList) to the console again.” As far as I can tell I’m doing it.
I have a suspicion that the “add” function is wrong, but it passed previous steps and is also what the learning env is returning for this step.

Your code so far

function initList() {
    return {
        head: null,
        length: 0
    };
}

function isEmpty(list) {
  return list.length === 0;
}

function add(list, element) {
    const node = {
        element: element,
        next: null
    };
}


// User Editable Region

let myList = initList();
console.log(isEmpty(myList));
add(myList, 49);
console.log(myList);
console.log(isEmpty(myList));

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

Challenge Information:

Build a Linked List - Step 5

Remove the semicolons after your log statements, and try again. Idk why but that worked my computer.

Welcome to the forum @Kerim!

And thank you for helping to make fCC better! A GitHub issue has been created.

Linked List - Step 5 expects no semi-colons after logs to pass tests · Issue #66772 · freeCodeCamp/freeCodeCamp

Happy coding!

1 Like

Can confirm this worked for me as well. No idea why…