Starting from:

$29.99

WEB222 SSA Assignment 1

WEB222 SSA Assignment 1
Objective
This assignment will help you practice JavaScript syntax, and use built-in and user-defined
functions.
Please do this assignment on your own, and submit only your own work. Gaining experience
with JavaScript and the web takes a lot of personal practice, and working on these problems
yourself will help build your skill.
Instructions
Below you will find various tasks that need to be completed. Write your solutions in a file
named assignment01.js. You can use the Firefox Scratchpad to run your code, or use
node.js.
Make sure you properly format all your code with correct indenting and spacing, declare all
variables before first use, include semi-colons, etc. You will lose marks if your code is not
properly written.
Task 1 - Format and Display Student Info
Write an implementation for the following function:
function displayStudentInfo(name, program, courses, hasJob) {
}
Your function should format the data passed to it, and display this info to the console as a
formatted string. Your function should work as shown below. A few things to note:
• The final argument `hasJob` is optional, and should be used to determine whether you
display “do” or “don’t” regarding the student’s part-time job.
• Depending on the value of `courses`, use either course (1) or courses (more than 1).
displayStudentInfo(“Jane Doe”, “CPA”, 5);
“My name is Jane Doe and I’m in the CPA program. I’m taking 5 courses this
semester, and I don’t have a part-time job.”
displayStudentInfo(“John Kim”, “BSD”, 1, false);
“My name is John Kim and I’m in the BSD program. I’m taking 1 course this
semester, and I don’t have a part-time job.”
displayStudentInfo(“Vivian Lee”, “CPA”, 3, true);
“My name is Vivian Lee and I’m in the CPA program. I’m taking 3 courses this
semester, and I do have a part-time job.”
Task 2 - Calculate Age Statistics
Write an implementation for the following function:
function calculateAgeStats(birthDate) {
}
Your function should use the birthDate (Date) passed to it, and subtract it from the current
date. Use this value (milliseconds) to calculate the number of hours that the person has been
alive. Your function should work as shown below. A few things to note:
• You can use the `Date` object and its methods to work with dates and do calculations. See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
• Make sure you throw away the decimal portion of the hours after you calculate it.
var dob = new Date("Dec 23, 2000");
calculateAgeStats(dob);
“You were born on Sat Dec 23 2000 and have been alive for approximately
155316 hours.”
Task 3 - Convert Temperatures From/To Celsius & Fahrenheit
Write an implementation for the following function to convert temperature values for a given
scale:
function convertTempFrom(value, scale) {
}
Your function should convert the `value` (a Number) from the given `scale` (a one
character String indicating Celsius (“c” or “C”) or Fahrenheit (“f” or “F”)) to the other scale. If
no scale is given, assume the scale is Celsius and return a value converted to Fahrenheit. If
the scale is unknown, return an error string:
// NOTE: values updated from previous version for conversion calculation.
convertTempFrom(50); should return “122 F”
convertTempFrom(50, “c”); should return “122 F”
convertTempFrom(50, “C”); should return “122 F”
convertTempFrom(14, “f”); should return “-10 C”
convertTempFrom(10, “F”); should return “-10 C”
convertTempFrom(56, “G”); should return “ERROR: Unknown Scale - G”
convertTempFrom(56, “k”); should return “ERROR: Unknown Scale - k”
Task 4 - Display Odd/Even for all numbers in a range
Write an implementation for the following function to print all numbers in a given range, and
whether they are odd or even:
function displayOddEven(rangeStart, rangeEnd) {
}
Your function should loop through all numbers in the range given, and print to the console
whether or not the number is odd or even:
displayOddEven(0, 10);
0 is even
1 is odd
2 is even
3 is odd
4 is even
5 is odd
6 is even
7 is odd
8 is even
9 is odd
10 is even
Task 5 - Find Largest Number
Write a function named findLargest as a function expression which takes any number of
values (Numbers) and returns the largest number. Your function should work like so:
findLargest(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); should return 10
findLargest(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10)); should return
-1
findLargest(200, 313, 5000, 2, -10, 9993513, 3, 2)); should return
9993513
Task 6 - Average Evaluator
Write a function named calculateAverage as a function declaration which takes any
number of values (Numbers), and returns their average. Your function should work like so:
calculateAverage(1, 2); should return 1.5
calculateAverage(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); should return 5.5
calculateAverage(77.2, 89, 57.4, 100, 62, 73, 87, 90); should return
79.45
Task 7 - Class Grades
Write a function named formatGrades as a function declaration which takes any number of
scores (Numbers) and formats them as letter grades. Within your formatGrades function,
write a function expression named letterFromScore which takes a single score (Number)
and returns a letter grade (String). Use a loop to call letterFromScore for each of the
scores passed to formatGrades. Your function should work like so:
formatGrades(77.2, 89, 57.4, 100, 62, 73, 87, 90) should print:
B A D A+ C B A A+
Submission
Write all your solutions to the tasks above in a file named assignment01.js. 
Submit your assignment01.js file to Blackboard / My.Seneca. If it won’t allow you to post a
file with .js as the extension, create a ZIP file and upload that instead.
No Late Submissions for the assignment will be accepted. You will receive a grade of 0 if you
do not submit on time. Blackboard manages the submission time, so give yourself lots of time
to get things uploaded.
Submission Deadline: Monday Sept 24, 2018 @ 11:00 PM
Assessment Weight: 5% of your final course grade

More products