[JS Practice] Valid The Coupon Code

Title :

Valid The Coupon Code

Description:

Your online store likes to give out coupons for special occasions. Some customers try to cheat the system by entering invalid codes or using expired coupons.

Your mission:
Write a function called checkCoupon to verify that a coupon is valid and not expired. If the coupon is good, return true. Otherwise, return false.

A coupon expires at the END of the expiration date. All dates will be passed in as strings in this format: “June 15, 2014”

Continue reading

Advertisements

[JS Practice] Find majuscule letters

Title :

Find majuscule letters

Description:

Instructions

Write a function capitals that takes a single string (word) as argument. The functions must return an ordered list containing the indexes of all capital letters in the string.

Example

Test.assertSimilar( capitals('CodEWaRs'), [0,3,4,6] );

Continue reading

[JS Practice] Difference of 2 (相差2)

Title :

Difference of 2

Description:

The objective is to obtain the various sets of integers that have a difference of 2 from a given array of integers. The result array should be sorted in ascending order of values.

So for example for the array of integers

[1,2,3,4] should return [[1,3],[2,4]]

[4,1,2,3] should also return [[1,3],[2,4]]

[1,23,3,4,7] should return [[1,3]]

Assume there are no duplicate integers in the array. The order of the integers in the input array should not matter.

Continue reading