JavaScript DOM Scripting By Example Editing and Filtering Names Moving to an Editing State

Myles Young
.a{fill-rule:evenodd;}techdegree seal-36
Myles Young
Full Stack JavaScript Techdegree Graduate 22,053 Points

I got it (with some help) check my comments for how It is done, and what is doing what!

else if(button.textContent === 'save'){ // making code for saving changes. return to what it was before edit const input = li.firstElementChild; //reference node const save = document.createElement('span'); //created new node save.textContent = input.value; //setting the save spans text content to = the input the user types li.insertBefore(save, input); li.removeChild(input); //to replace old span with new span button.textContent = 'edit'; }

Myles, your code is a bit hard to read in that format, but it appears you did more or less the same thing I did! The only difference is instead of creating a constant named save, I named mine span, just like it was in the block for "edit." In my opinion it keeps things consistent and easier to understand, especially since in this context "save" is also the text content of the button.

    } else if (button.textContent === 'save') {
      const input = li.firstElementChild;
      const span = document.createElement('span');
      span.textContent = input.value;
      li.insertBefore(span, input);
      button.textContent = 'edit';