Skip to content

Instantly share code, notes, and snippets.

Avatar

Mantoh Nasah Kuma Nasah-Kuma

View GitHub Profile
View strongPassword.js
/*
* Complete the 'minimumNumber' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. INTEGER n
* 2. STRING password
*/
function minimumNumber(n, password) {
View camelCase.js
function camelcase(s) {
// Write your code here
let wordCount = 1;
let i = 0;
while (i < s.length) {
if(s[i].toUpperCase() === s[i]) wordCount++;
i++;
}
return wordCount;
}
View climbingLeaderboard.js
/*
* Complete the 'climbingLeaderboard' function below.
*
* The function is expected to return an INTEGER_ARRAY.
* The function accepts following parameters:
* 1. INTEGER_ARRAY ranked
* 2. INTEGER_ARRAY player
*/
function climbingLeaderboard(ranked, player) {
View bonAppetit.js
/*
* Complete the 'bonAppetit' function below.
*
* The function accepts following parameters:
* 1. INTEGER_ARRAY bill
* 2. INTEGER k
* 3. INTEGER b
*/
function bonAppetit(bill, k, b) {
View birthdayCandle.js
function birthdayCakeCandles(candles) {
const max = Math.max(...candles);
let counter = 0;
for(let candle of candles) {
if (candle === max) counter++;
}
return counter;
}
View staircase.js
/*
* Complete the 'staircase' function below.
*
* The function accepts INTEGER n as parameter.
*/
function staircase(n) {
// Write your code here
let newString = '';
let j = n-1;
View migratoryBirds.js
function migratoryBirds(arr) {
// Write your code here
let countA = 0;
let countB = 0;
let countC = 0;
let countD = 0;
let countE = 0;
for (let item of arr) {
switch (item) {
case 1: countA++;
View dayOfProgrammer.js
function dayOfProgrammer(year) {
// Write your code here
let feb = 0;
let initialDaySum = 0;
if (year >= 1700 && year <= 1917) {
if (year % 4 === 0) feb = 29;
else feb = 28;
}
else if (year > 1918 && year <= 2700) {
View breakingRecords.js
function breakingRecords(scores) {
// Write your code here
let [min, max] = [0, 0];
let minScore = scores[0];
let maxScore = scores[0];
for(let i = 1; i < scores.length; i++) {
if (scores[i] < minScore) {
min++;
minScore = scores[i];
} else if(scores[i] > maxScore) {
View kangaroo.js
/*
* Complete the 'kangaroo' function below.
*
* The function is expected to return a STRING.
* The function accepts following parameters:
* 1. INTEGER x1
* 2. INTEGER v1
* 3. INTEGER x2
* 4. INTEGER v2
*/