Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA script Problem : count valid postal codes for a given province code * * The countForProvince() function takes a two-character province code, and

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

}


Step by Step Solution

There are 3 Steps involved in it

Step: 1

To solve this problem you need to iterate over the postal codes provided check if each postal code b... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

An Introduction to Management Science Quantitative Approach to Decision Making

Authors: David R. Anderson, Dennis J. Sweeney, Thomas A. Williams, Jeffrey D. Camm, James J. Cochran

15th edition

978-1337406529

More Books

Students also viewed these Programming questions