Have excercises to suggest? See Contribution guide
flatten([
[1, 2],
[3, 4],
[5, 6]
]); // -> [1,2,3,4,5,6]
sum([1, 2, 3, 4]); // -> 10
- Write a function that takes in array of simple values (numbers,strings) and returns original array without duplicated records (Code/Test)
unique([1, 2, 3, 4, 5, 2, 3, 4, 1]); // -> [1,2,3,4,5]
getNthElement([1, 2, 3, 4, 5, 6, 7, 8], 4); // -> [4,8]
- Write a function that returns first
n
elements of array
getFirstElements([1, 2, 3, 4, 5], 3); // -> [1,2,3]
- Write a function that takes in a list of numbers and returns difference between smallest and largest value (Code/Test)
arrayValueDiff([1, 2, 3, 4]); // -> 3
arrayValueDiff([-1, 2, 3, 5]); // -> 6
arrayValueDiff([3, 3, 3]); // -> 0
countValueOccurences([1, 2, 3, 4, 5, 2, 3, 1, 2], 2); // -> 3
multiply([1, 2, 3, 4]); // -> 24
- Given a map of employee salaries return sum of all salaries
const salariesExample = {
Max: 50,
Anna: 50,
John: 100
};
sumSalaries(salariesExample); // -> 200
composeQueryString({ version: 1, user: "Mike", country: "BLR" }); // -> “?version=1&user=Mike&country=BLR”
- Write a function that takes in a collection of items, a parameter value and returns a hash map of lists entities groupped by parameter value (Code/Test)
composeGroupsByProperty([
{ age: 20, name: "Peter" },
{ age: 30, name: "Mike" }
]);
// -> {20:[{age:20,name:"Peter"}],30:[{age:30,name:"Mike"}]}
const map = {
"Holly Jackson": 250,
"Jack Southerland": 100,
"Peter Higgins": 50
};
findHighestHashValue(map); // -> "Holly Jackson"
const baseObject = { xml: 4, http: 2, rest: 2, js: 10 };
const baseFields = ["xml", "js"];
mapObject(baseObject, baseFields); // -> { xml: 4, js: 10 };
- Given a string that represents a chain of object properties return the value from the chain (Code/Test)
const data = {
version: "0.6",
account: {
isProtected: true
}
};
searchInChain("version",data); // -> 0.6
searchInChain("account",data); // -> {isProtected: true}
searchInChain("account.isProtected",data); // -> true
isPalindrome("xanax"); // -> true
isPalindrome("xanax2"); // -> false
composeAbbreviation("Denial Of Service"); // -> "DOS"
composeAbbreviation("United Nations"); // -> "UN
greaterThan1000("200 150 1200 400 20 1400"); // -> “1200 1400”.
getFirstRecurringCharacter("ABCDEA"); // -> “A”
- Write a function that takes in a string and returns whether the first character of a string is in uppercase (Code/Test)
isFirstCharacterUppercase("ABCDEA"); // -> true
isFirstCharacterUppercase("abcdea"); // -> false
- Write a function that takes in a string and a number
n
of repetitions and returns new string, that is original string repeatedn
times (Code/Test)
composeCharacterSequence({ sequence: "+", repeatCount: 5 }); // -> "+++++"
- Write a function that takes in a string and an array of characters. If a string has a character that’s included in an array then make the character uppercase. (Code/Test)
targetUppercase("123xyzabc", ["x", "c"]); // -> ‘123XyzabC’;
- Write a function that takes in a string and returns an object with the following properties of the given string: (Code/Test)
- length of the string
- number of unique characters used to compose a string
- Hash table with the following format -> {character: number of times character occurs in the string};
const string = "abcdeabc";
const heatmap = getHeatmap(string);
/*
heatmap.length -> 8;
heatmap.uniqueTokensCount -> 5;
heatmap.map -> {
a: 2,
b: 2,
c: 2,
d: 1,
e: 1
};
*/
toCamelCase("A string of values"); // -> "aStringOfValues";
getCapitalizedWords("Visit United States of America today!"); // -> ["Visit","United","States","America"]
- Given a string that contains snake_case'd words, return a string where those words are surrounded with provided HTML tag. (Code/Test)
surroundSnakeCase(
"a_snake_case_word followed by normal word and then snake_case_again",
"h1"
); // -> "<h1>a_snake_case_word</h1> followed by normal word and then <h1>snake_case_again</h1>"
fuzzySearch("car", "cartwheel"); // -> true
fuzzySearch("cwhl", "cartwheel"); // -> true
fuzzySearch("cwheel", "cartwheel"); // -> true
fuzzySearch("cartwheel", "cartwheel"); // -> true
fuzzySearch("cwheeel", "cartwheel"); // -> false
fuzzySearch("lw", "cartwheel"); // -> false
getParenthesisValidity("()"); // -> true
getParenthesisValidity("()()"); // -> true
getParenthesisValidity("(()())"); // -> true
getParenthesisValidity(")("); // -> false
getParenthesisValidity("())"); // -> false