CNIT 133 Homework 6 - Objects

CNIT 133 Main Page

function

Part1: First part of this assignment uses math methods provided by javascript in-built libraries to format an input floating point number, entered with at least 4 digits after decimal, to 4 different types of float. The script also calculates the closest integer to the square root of the number.

Part2: Second part of this assignment inputs some text and a character to be searched in the input text. The script counts the occurrence of the character in the text using string method charAt. In case of 0 occurrence, a new window pops to report the result.

Part3: Third part of this assignment inputs phone number in this format: (999) 999-9999. It uses regex to validate the formatting of the input and if valid, it uses string method split to split the phone number into area code, first 3 and last 4 digits of the number.