Just a quick back-end project for reading and writing to a JSON file!
- VERY IMPORTANT! You'll be working in the
students.json
file, but to make sure your workflow can remain consistent with the past projects (mainly yourjest --watch-all
capability), you're going to have to movestudent.json
exactly one level up from this repo. - Otherwise (and because of that step), this will be your typical test-driven workflow.
getStudentByIndex
- given an index, returns the student with that index from the students array in thestudents.json
filegetStudentByName
- given a first name, returns the student with that name from the students array in thestudents.json
file, and returns -1 if they're not foundgraduateStudent
- given a student's name, up their term by 1 and write it back to thejson
file
- Check out the JSON file (which you DID move one level up, right??) for reference.
- Use
fs
to read and write the file (and it MUST be the methods withsync
at the end of their names!),JSON.parse()
to change the JSON to an object, andJSON.stringify()
to get it back to a string you can write to the file. - The tests will run a little slowly from all the reading and writing to your disk. Be patient!
- Don't worry about mutation. Let's keep to that simple if bad-practice technique for this one.