Nodejs代写 | COMP 2406A Winter 2021 – Tutorial #1

这个作业是用Nodejs完成一些基础的JavaScript编程题
COMP 2406A
Winter 2021 – Tutorial #1

Problem 1 (Installing Node.js)
Go to https://nodejs.org/en/ and download/install Node.js version 14.x. You can change
the installation location if you want but be sure not to deselect any of the features on the
‘custom setup’ page of the installation wizard; the default options will install everything
we need.
Once installed, you should be able to run the command node -v from the command
line and see the version number printed out. If you did this successfully, Node.js is now
installed on your computer. Node comes packaged with a second application called
NPM. We will not need NPM for this tutorial, but you should check that it installed
correctly by running npm -v in the command line. If it prints out a version number, you’re
good to go.
Problem 2 (A Basic Javascript Program)
Write a program that prints out the following pattern to the console (7 rows):
#
##
###
####
#####
######
#######
Your program should contain no more than one console.log() statement (looped over
multiple times) and you should be able to adjust the number of rows printed by changing
one number within your code. Save your code in a file with the .js file extension and
execute it using Node.js.
Problem 3 (Working with Javascript Strings)
Download the stringproblems.js file from cuLearn. Run the code with Node.js. It will
write output to the console window. It should produce a simple string output meant to
look like a landscape profile like this:
___/””\______/’\_
Modify this code so that it uses the ‘_’ underscore character for both the flat portions
and the tops of the hills. Before you start, think about how you need to modify the
existing code to accomplish this. Think about what you would need to do to put an
underscore ‘above’ a line of text. You may need more variables and/or more lines of text
in the result. The output should now look like:
Problem 4 (Higher Order Array Functions)
Download the students.js file from cuLearn. This file contains an array called students,
which contains several Javascript objects representing student information. Add code to
this file which uses the higher order array functions (filter(), map(), reduce()) to
generate and output the information required below:
1. Generate an array containing the first names of all students. Print it to the console to
verify.
2. Generate and print an array containing the full names of students (first and last name
separated by “ “) of all students who received an exam grade of 80 or higher. The
students should be [ ‘James Johnson’, ‘Stephanie Ottesen’, ‘Leonard Arvan’, ‘Beverly
Mott’, ‘Beatrice Jaco’ ]
3. Generate and print the total average final grade of all students. Each student’s final
grade should be calculated with the weighting: assignment=40%, tutorial=10%,
exam=50%. The average of all grades should be ~ 71.36%.