/*******************************************************************************
*
* Welcome to Assignment 1! In this assignment, you're going to bepracticing lots
* of new JavaScript programming techniques. You'll see commentslike this one:
*
* @param {String} name - the name to greet in the message
*
* These are specially formatted comments that define parameters tofunctions,
* and tell use the type {String} or {Number}, and also theparameter's name.
* Finally, we also explain a bit about how the parameter is used,and what
* data it will have, whether it's optional, etc.
* Please complete this js file by writing the code in the specifiedareas and then submit the assignment on blackboard
*******************************************************************************
* Problem 1: remove all spaces and dashes from a String value, andmake it lowercase.
*
* We want to be able to \"crush\" a string so that it contains nospaces or dashes,
* and all letters are lower case. The crush() function should worklike this:
*
* crush('ABC') --> returns 'abc' (all lowercase)
* crush('abc') --> returns 'abc' (the string was alreadycorrect, same value)
* crush('A BC') --> returns 'abc' (lowercase, spaceremoved)
* crush('a b- c') --> returns 'abc' (lowercase, spaces removed,dash removed)
*
* @param {String} value - a string to be crushed
******************************************************************************/
function crush(value) {
// Replace this comment with your code...
}
/*******************************************************************************
* Problem 3: extract the Forward Sortation Area (FSA) from a PostalCode
*
* The first three letters of a Canadian Postal Code are known as aforward
* sortation area, and designate a geographic unit. See detailsat:
*
* https://www.ic.gc.ca/eic/site/bsf-osb.nsf/eng/br03396.htmland
*https://en.wikipedia.org/wiki/Postal_codes_in_Canada#Components_of_a_postal_code
*
* Given a postal code, you are asked to extract the FSA. If theresulting FSA
* is invalid, you should throw an error message, otherwise returnthe extracted FSA.
*
* For example:
*
* extractFSA('M2J 2X5') --> returns 'M2J' (valid FSA for NewnhamCampus)
* extractFSA('2MJ X25') --> throws an Error with the message,'invalid FSA'
*
*
*
* A valid FSA is defined as:
*
* - first character is a letter, one of A, B, C, E, G, H, J, K, L,M, N, P, R, S, T, V, X, Y (not D, F, I, O, Q, U, W)
* - second character is a digit, one of 0, 1, 2, 3, 4, 5, 6, 7, 8,9
* - third character is any letter (A to Z)
*
* @param {String} postalCode - a postal code
******************************************************************************/
function extractFSA(postalCode) {
// Replace this comment with your code...
}
/*******************************************************************************
* Problem 4: convert an Age (number) to an Age Range Category(string)
*
* For statistical reasons, we are interested in taking literal ageslike 21, 23, 26, etc
* and converting them to the string '20 to 29 years' so that we cando grouping.
*
* The ageToRange() function takes an age as a Number and returnsthe appropriate
* age range category string:
*
* ageToRange(21) --> returns '20 to 29 years'
* ageToRange(29) --> returns '20 to 29 years'
* ageToRange(30) --> returns '30 to 39 years'
*
* The age range categories you need to support are asfollows:
*
* '19 and younger',
* '20 to 29 Years',
* '30 to 39 Years',
* '40 to 49 Years',
* '50 to 59 Years',
* '60 to 69 Years',
* '70 to 79 Years',
* '80 to 89 Years',
* '90 and older'
*
* Your ageToRange() function should accept age Numbers from 0 to125. If the
* age passed to your function is outside 0 to 125, throw an Errorwith the message
* 'invalid age'.
*
* @param {Number} age - the age of the person
******************************************************************************/
function ageToRange(age) {
// Replace this comment with your code...
}