Question: SOLVE USINH JAVASCRIPT Problem 7: count valid postal codes for a given province code * * The countForProvince() function takes a two-character province code, and

SOLVE USINH JAVASCRIPT

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

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!