fullstack-hy2020 / fullstack-hy2020.github.io

https://fullstack-hy2020.github.io
Other
1.53k stars 3.84k forks source link

Removed String() frrom addNote function #3749

Closed arkadx13 closed 1 month ago

arkadx13 commented 1 month ago

Removed String() function from creating id for noteObject. The current result is having an id of type string for newly created notes. This is different from the initial data of notes having data type number for id on each note.

mluukkai commented 1 month ago

id in now a string

arkadx13 commented 1 month ago

id in now a string

How come in the github repo it doesnt have that String function? Which one is correct? https://github.com/fullstack-hy2020/part2-notes-frontend/blob/part2-2/src/App.jsx

  const addNote = (event) => {
    event.preventDefault()
    const noteObject = {
      content: newNote,
      important: Math.random() > 0.5,
      id: notes.length + 1,
    }

    setNotes(notes.concat(noteObject))
    setNewNote('')
  }