PencilCoder

The O in I/O!

Goals:

  • Save data to the Pencil Code server using the save function
  • Use save and load together to maintain a permanent record of program data, such as high scores or answers from a survey
  • Ulilize the JSON data-interchange format to facilitate reading and writing data formatted as arrays and other javascript objects

Coding Snippets:

  • coding snippets
  • Data passed to save must be in string form. Convert objects to strings using the JSON.stringify() method.
  • The JSON.parse() method converts JSON data back to its original form.

Math and Computer Concepts:

  • JSON is a widely used file format that is easy for humans to read and write and easy for machines to parse and generate. JSON simplifies the process of reading and writing data used in computer programs.
  • Similar to load, save executes asynchronously. Use the the await and defer functions as illustrated below to force your program to wait for the asynchronous save process to complete before moving on to subsequent code in your script:

Activities:

Save each of the following in a folder called IO.