[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

Advertisements

[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