/NoteTaker

Homework for UC Berkeley Extension

Primary LanguageJavaScript

Note Taker

Project realized for UC Berkeley Extension Coding Bootcamp

License: MIT

Site

Technologies Used

HTML   JavaScript   JavaScript   JavaScript  



Summary

This App allows you to write, save, and delete notes efficiently. The notes are consistent and stored on your local machine for full privacy.



How to install

Download the project on your local machine. Make sure you have node installed then at the root of the folder run the command:

npm install


How to use it

run the commande

node server.js

then visit: http://localhost:3000/



Code Snippet

app.delete('/api/notes/:id', (req, res) => {
  var deletion = req.params.id
  for(var i = 0; i < notes.length; i++) {
      if(deletion == notes[i].id) {
        notes.splice(i, 1);
        break;
      }
      
  }
  fs.writeFile(path.join(__dirname, 'db/db.json'), JSON.stringify(notes), err => { });
  res.redirect('/notes');
});

In this example, I used the splice method to delete the selected note from the JSON object, then stringify it and save it inside the db.json file using fs.



Result Example

Link



Author