Assignments Node I

Handing In Assignments

You must hand in by using git

Hand In by git

  • Create an empty repo on bitbucket.org, gitlab.com, or github.com,
  • git push your local repo to the above remote repo.
  • For node assignments please put the line(s)

    node_modules/

    into your .gitignore file.

Send a mail to with:

  • The word 'handin <subjectname>' in the subject line of your mail
  • The url of your repo(s).

Assignment Node I.0

This assignment is to follow in the steps of your textbook, [Wex19] section 3.2. Please notice the procedural remark about .gitignore.

Assignment Node I.0a

Write a module containing af function that returns true if all provided parameters have values, and false otherwise.

Assignment Node I.1

In the browser, the window object has a prompt method. We don't have the window. Here is a code snippet as a helper:

// on console: npm i readline-sync

const readline = require('readline-sync');
let name = readline.question("Enter name: ");
console.log(`Hi ${name}`);

Now write a JavaScript/node program requesting the user to enter a userid on the console. Then ask her to enter an email address on the console. When both have been accomplished, write the two pieces of information into a text file on your computer.

You might consider using the module from the previous assignment to check for values in the user entered data.

Think about the format for storing the information in the file. Make a comment in the program that reflects your choice and why.

Assignment Node I.2

Write a JavaScript/node program that reads user/email values from the file from the section called “Assignment Node I.1” and prints them on the console.

Assignment Node I.3

Write a JavaScript/node program that prompts the user for a userid, then searches for that particular userid in the file from the section called “Assignment Node I.1” and returns the corresponding email address on the console.

Assignment Node I.4

Write a new version of the program from the section called “Assignment Node I.1” so that it allows only one entry for each userid. This means that if the userid already exists, the entry should be rejected.

Assignment Node I.5

Write yet another version of the program from the section called “Assignment Node I.1” so that it allows only one entry for each userid. In this case if the userid already exists, the entry should be changed to the new email address.