Description
Assessment Weight:
6% of your final course Grade
Objective:
Practice JavaScript basic syntax, built‐in functions, and user defined functions.
Specification:
Write a JavaScript program assignment01.js to perform the following tasks. No validation is required for user input – assume that the user will enter valid information.
Create comment line(s) for each of the Tasks using block comments, indicating the start point of each Task. e.g.
/*****************************
* Task 1
*****************************/
Task 1: Description as Comments
In a comment section, describe the following terms with examples (Your code example may appear in comments). a) Infinity
- Undefined
- NaN
Task 2: Conversion
- Using appropriate method, convert 1010 (binary) to decimal, AF (hex) to decimal and 713 (Octal) to decimal. Output appropriate messages to the console for each conversion.
Task 3: Celsius and Fahrenheit temperatures a) Store a Celsius temperature in a variable.
- Convert it to Fahrenheit and output: “???C is ???F”. //??? Represents the value
- Store a Fahrenheit temperature into a variable.
- Convert it to Celsius and output: “???F is ???C.”
Note: visit www.manuelsweb.com/temp.htm for temperature conversion formula.
Task 4: Larger or largest number
- Write a function named largerNum using the declaration approach, the function:
takes 2 arguments, both numbers, returns the larger (greater) one of the 2 numbers.
- Write a function named greaterNum using the expression approach, the function:
takes 2 arguments, both numbers, returns the greater (larger) one of the 2 numbers.
- Call these functions twice with different number parameters, and log the output to the web console with descriptive outputs each time (e.g. “The larger number of 5 and 12 is 12.”).
Task 5: Evaluator
- Write a function named Evaluator using the declaration approach, the function:
takes unknown number of arguments which are all number scores, returns true if the average of these number scores is greater than or equal to 25. Otherwise return
false.
- Call this function 3 times with different number parameters, and log the output to the web console with descriptive outputs each time (e.g. “Average grater than or equal to 25: false”);
Task 6: ShowMultiples
- a) Write a function called showMultiples using the declaration approach, the function:
Takes 2 numeric arguments (num, numMultiples) – assume the user is entering valid (positive) whole numbers
Outputs all of the multiples of the num argument from 1 to numMultiples: for example: if num = 5 and numMultiples = 4, the function would output:
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15 5 x 4 = 20
- b) Call this function 3 times with different number parameters, and log the output to the web console with descriptive outputs each time.
Task 7: Closure/Self Invoking
Use JavaScript Closure/self invoking method to do the following: a) Name the outer function as ‘Increment”.
- Store 100 as a counter in the outer function.
- Increment the counter by 100 in the inner function and return.
- Call “Increment” three times and store the returned value in a variable each time.
- Log the final value in the web console (400 is the final value for the third call).
Special Note: You are not allowed to use prompt / alert anywhere in your code. All input data should be hard coded so that one run generates uninterrupted output data for all 7 tasks. Make sure output does not throw undefined anywhere.





