Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f5a160a

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

File tree

11 files changed

+150
-0
lines changed

11 files changed

+150
-0
lines changed

‎README.md

Lines changed: 3 additions & 0 deletions
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

Lines changed: 16 additions & 0 deletions
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));

‎completed_exercises/1-reverse-string.js

Lines changed: 25 additions & 0 deletions
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

Lines changed: 18 additions & 0 deletions
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

Lines changed: 27 additions & 0 deletions
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+

‎completed_exercises/4-array-chunking.js

Lines changed: 11 additions & 0 deletions
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

Lines changed: 11 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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) {}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /