Skip to content

Commit f5a160a

Browse files
author
Coding Money
committed
initial commit
0 parents  commit f5a160a

11 files changed

+150
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# js-coding-interview-questions
2+
3+
This repo has been created in support for the Coding Money tutorial videos on youtube. If you want to follow along check out the youtube channel at: http://youtube.com/CodingMoney

completed_exercises/1-reverse-int.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// --- Directions
2+
// Given an integer, return an integer that is the reverse
3+
// ordering of numbers.
4+
// --- Examples
5+
// reverseInt(15) === 51
6+
// reverseInt(981) === 189
7+
// reverseInt(500) === 5
8+
// reverseInt(-15) === -51
9+
// reverseInt(-90) === -9
10+
11+
function reverseInt(n) {
12+
const reversed = n.toString().split('').reverse().join('')
13+
return parseInt(reversed) * Math.sign(n)
14+
}
15+
16+
console.log(reverseInt(-15));
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// --- Directions
2+
// Given a string, return a new string with the reversed order of characters
3+
// --- Examples
4+
// reverse('hi') === 'ih'
5+
// reverse('hello') === 'olleh'
6+
// reverse('CodingMoney') === 'yenoMgnidoC'
7+
8+
function reverse(str) {
9+
10+
return str.split('').reverse().join('')
11+
12+
}
13+
14+
console.log(reverse('CodingMoney'));
15+
16+
17+
// function reverse(str) {
18+
// let reversed = ''
19+
20+
// for(let char of str){
21+
// reversed = char + reversed
22+
// }
23+
24+
// return reversed
25+
// }

completed_exercises/2-palindrome.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// --- Directions
2+
// Given a string, return true if the string is a palindrome
3+
// or false if it is not. Palindromes are strings that
4+
// form the same word if it is reversed.
5+
6+
// --- Examples:
7+
// palindrome("kayak") === true
8+
// palindrome("madam") === true
9+
// palindrome("codingmoney") === false //yenomgnidoc
10+
11+
function palindrome(str) {
12+
const reversed = str.split('').reverse().join('')
13+
14+
return str === reversed
15+
16+
}
17+
18+
console.log(palindrome('codingmoney'));

completed_exercises/3-maxchars.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// --- Directions
2+
// Given a string, return the character that is most
3+
// commonly used in the string.
4+
// --- Examples
5+
// maxChar("abcccccccd") === "c"
6+
// maxChar("apple 1231111") === "1"
7+
8+
function maxChar(str) {
9+
const charMap = {}
10+
let max = 0
11+
let maxChar = ''
12+
for(let char of str){
13+
charMap[char] = ++charMap[char] || 1
14+
}
15+
16+
for(let key in charMap){
17+
if(charMap[key] > max){
18+
max = charMap[key]
19+
maxChar = key
20+
}
21+
}
22+
23+
return maxChar
24+
}
25+
26+
console.log(maxChar("apple 1231111"));
27+
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// --- Directions
2+
// Given an array and chunk size, divide the array into many subarrays
3+
// where each subarray is of length size
4+
// --- Examples
5+
// chunk([1, 2, 3, 4], 2) --> [[ 1, 2], [3, 4]]
6+
// chunk([1, 2, 3, 4, 5], 2) --> [[ 1, 2], [3, 4], [5]]
7+
// chunk([1, 2, 3, 4, 5, 6, 7, 8], 3) --> [[ 1, 2, 3], [4, 5, 6], [7, 8]]
8+
// chunk([1, 2, 3, 4, 5], 4) --> [[ 1, 2, 3, 4], [5]]
9+
// chunk([1, 2, 3, 4, 5], 10) --> [[ 1, 2, 3, 4, 5]]
10+
11+
function chunk(array, size) {}

exercises/1-reverse-int.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// --- Directions
2+
// Given an integer, return an integer that is the reverse
3+
// ordering of numbers.
4+
// --- Examples
5+
// reverseInt(15) === 51
6+
// reverseInt(981) === 189
7+
// reverseInt(500) === 5
8+
// reverseInt(-15) === -51
9+
// reverseInt(-90) === -9
10+
11+
function reverseInt(n) {}

exercises/1-reverse-string.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// --- Directions
2+
// Given a string, return a new string with the reversed order of characters
3+
// --- Examples
4+
// reverse('hi') === 'ih'
5+
// reverse('hello') === 'olleh'
6+
// reverse('CodingMoney') === 'yenoMgnidoC'
7+
8+
function reverse(str) {}

exercises/2-palindrome.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// --- Directions
2+
// Given a string, return true if the string is a palindrome
3+
// or false if it is not. Palindromes are strings that
4+
// form the same word if it is reversed.
5+
6+
// --- Examples:
7+
// palindrome("kayak") === true
8+
// palindrome("madam") === true
9+
// palindrome("codingmoney") === false
10+
11+
function palindrome(str) {}
12+

exercises/3-maxchars.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// --- Directions
2+
// Given a string, return the character that is most
3+
// commonly used in the string.
4+
// --- Examples
5+
// maxChar("abcccccccd") === "c"
6+
// maxChar("apple 1231111") === "1"
7+
8+
function maxChar(str) {}

exercises/4-array-chunking.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// --- Directions
2+
// Given an array and chunk size, divide the array into many subarrays
3+
// where each subarray is of length size
4+
// --- Examples
5+
// chunk([1, 2, 3, 4], 2) --> [[ 1, 2], [3, 4]]
6+
// chunk([1, 2, 3, 4, 5], 2) --> [[ 1, 2], [3, 4], [5]]
7+
// chunk([1, 2, 3, 4, 5, 6, 7, 8], 3) --> [[ 1, 2, 3], [4, 5, 6], [7, 8]]
8+
// chunk([1, 2, 3, 4, 5], 4) --> [[ 1, 2, 3, 4], [5]]
9+
// chunk([1, 2, 3, 4, 5], 10) --> [[ 1, 2, 3, 4, 5]]
10+
11+
function chunk(array, size) {}

0 commit comments

Comments
 (0)