JAVA script Problem : count valid postal codes for a given province code * * The
Question:
JAVA script
Problem : 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...
}
An Introduction to Management Science Quantitative Approach to Decision Making
ISBN: 978-1337406529
15th edition
Authors: David R. Anderson, Dennis J. Sweeney, Thomas A. Williams, Jeffrey D. Camm, James J. Cochran