Help me with the JavaScript of this questions…

Question Answered step-by-step Help me with the JavaScript of this questions… Help me with the JavaScript of this questions/******************************************************************************* * Problem 4: convert a valid Canadian Postal Code to a Canadian Province * * The first letter of a Postal Code tells us which province the Postal Code is * from. Here’s the list of Provinces/Territories, their 2-letter short form, * and the first letter(s) of the Postal Code that matches it: * * Province Name                    Short Form      First Letter of Postal Code * —————————————————————————– * Ontario                          ON              K, L, M, N, P * Quebec                           QC              G, H, J * Nova Scotia                      NS              B * New Brunswick                    NB              E * Manitoba                         MB              R * British Columbia                 BC              V * Prince Edward Island             PE              C * Saskatchewan                     SK              S * Alberta                          AB              T * Newfoundland and Labrador        NL              A * Nunavut, Northwest Territories   NT              X * Yukon                            YT              Y * * The toProvince() function converts a valid postal code to a province name. Use * your fixPostalCode() function from the previous problem to format and validate * the `postalCode` argument first. If it is invalid, return `null`. HINT: use try/catch * to deal with fixPostalCode() throwing an error, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try…catch * * If the `useShortForm` argument is `true`, the province’s short-form is * returned instead of the full name.  For example: * * toProvince(‘M5W1E6’) returns ‘Ontario’ * toProvince(‘M5W 1E6’) returns ‘Ontario’ * toProvince(‘M5W 1E6’, true) returns ‘ON’ * toProvince(‘M5W’) returns null * * @param {string} postalCode – a postal code to be validated and used * @param {boolean|undefined} useShortForm – whether to return the full or short name * @returns {string} – a province name or short form ******************************************************************************/ function toProvince(postalCode, useShortForm) {// Code Here} /******************************************************************************* * Problem 7: count valid postal codes for a given province code * * The countForProvince() function takes a two-character province code, and * any number of postal codes, some of which may be invalid.  It returns the * total number of postal codes for the province represented by the two-character * code. * * For example: * * countForProvince(‘ON’, ‘M5W 1E6’) returns 1 * countForProvince(‘ON’, ‘Y0A 1L0’) returns 0 * countForProvince(‘ON’, ‘M5W 1E6’, ‘N0B 1K0’) returns 2 * countForProvince(‘ON’, ‘M5W 1E6’, ‘N0B 1K0’, ‘Y0A 1L0’) returns 2 * countForProvince(‘ON’, ‘INVALID’, ”, ‘Y0A 1L0’) returns 0 * * Use the toProvince() function you wrote earlier in your answer. * * Throw an error if no postal codes are passed, or if any of the postal codes * is not a string. * * @param {string} provinceCode – a two character province code * @param {string} …postalCodes – one or more postal code strings * @returns {number} the total, or 0 ******************************************************************************/ function countForProvince(provinceCode, …postalCodes) {  // Replace this comment with your code…}  Engineering & Technology Computer Science WEB 222 Share QuestionEmailCopy link Comments (0)