Tell us what’s happening:
Unable to proceed with step 6… I followed the instructions and assign node to list.head as well as increment the length property of list, but the hint would tell me that I should increment the length property of list.
If I use bracket notation instead, the hint would switch to telling me that I should assign node to list.head.
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
list.head = node;
list.length += 1;
// User Editable Region
}
const myList = initList();
console.log(isEmpty(myList))
add(myList, 42);
console.log(myList)
console.log(isEmpty(myList))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0
Challenge Information:
Build a Linked List - Step 6