[Solved] WEB222-Assignment 1

$25

File Name: WEB222-Assignment_1.zip
File Size: 178.98 KB

SKU: [Solved] WEB222-Assignment 1 Category: Tag:
5/5 - (1 vote)

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

  1. Undefined
  2. NaN

Task 2: Conversion

  1. 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.

  1. Convert it to Fahrenheit and output: ???C is ???F. //??? Represents the value
  2. Store a Fahrenheit temperature into a variable.
  3. 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

  1. 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.

  1. 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.

  1. 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

  1. 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.

  1. 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

  1. 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

  1. 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.

  1. Store 100 as a counter in the outer function.
  2. Increment the counter by 100 in the inner function and return.
  3. 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).

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] WEB222-Assignment 1
$25