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