Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
968cd6c
inital pirate files
john-ko29 Aug 12, 2020
a23c2fb
accumlate product complete
john-ko29 Aug 16, 2020
e1ccc68
algrebra sequence exercise complete
john-ko29 Aug 17, 2020
30bfe6c
all about string exercise complete
john-ko29 Aug 18, 2020
eb1c462
alternating cap ex complete
john-ko29 Aug 19, 2020
96c2a39
alternate zero and ones complete
john-ko29 Aug 20, 2020
3a2f6b5
alliteration complete
john-ko29 Aug 21, 2020
f62ba67
are letters in second string present in first complete
john-ko29 Aug 22, 2020
16aad27
atm exercise done
john-ko29 Aug 23, 2020
f366c7d
automorphic number complete
john-ko29 Aug 24, 2020
e46ecc5
barbecue challenge complete
john-ko29 Aug 25, 2020
d683341
basic email validation complete
john-ko29 Aug 26, 2020
78d33ba
bird names abbrev complete
john-ko29 Aug 27, 2020
2fa375b
blackjack exercise complete
john-ko29 Aug 28, 2020
419f236
box exercise complete
john-ko29 Aug 29, 2020
84b0666
calculate the difference complete
john-ko29 Aug 30, 2020
517311f
calculate distance complete
john-ko29 Aug 31, 2020
c362b8b
capitalize first letter complete
john-ko29 Sep 1, 2020
650e360
capitalize name complete
john-ko29 Sep 2, 2020
a0b6a3d
anagram challenge complete
john-ko29 Sep 3, 2020
fa91b79
check prime number complete
john-ko29 Sep 4, 2020
f78a87a
check array done
john-ko29 Sep 5, 2020
f4b5aa5
inital files for palindrome
john-ko29 Sep 6, 2020
a6068a6
check palindrome complete
john-ko29 Sep 7, 2020
8b650cd
chocolate excercise complete
john-ko29 Sep 8, 2020
4912be6
attempted tree
john-ko29 Sep 9, 2020
a0919d7
attempted tree
john-ko29 Sep 10, 2020
4cbcd41
attempted tree
john-ko29 Sep 11, 2020
e720436
Compoundiing letters
john-ko29 Sep 12, 2020
d39f6e1
convenience complete
john-ko29 Sep 13, 2020
5b85ad3
convert key values to array
john-ko29 Sep 14, 2020
baa898b
convert number complete
john-ko29 Sep 15, 2020
82f8c90
count letter
john-ko29 Sep 16, 2020
a9977e1
count one binary
john-ko29 Sep 17, 2020
3d605f1
count letters and digits
john-ko29 Sep 18, 2020
4066e76
count dup complete
john-ko29 Sep 19, 2020
89066db
cumulative array sum complete
john-ko29 Sep 20, 2020
4fd10b0
delete extra elements
john-ko29 Sep 21, 2020
f8b9a9f
digit distance complete
john-ko29 Sep 22, 2020
28a7f77
divide array complete
john-ko29 Sep 23, 2020
222566a
double letter complete
john-ko29 Sep 24, 2020
6aaa24d
equality of 3 complete
john-ko29 Sep 25, 2020
423ed37
factorize complete
john-ko29 Sep 26, 2020
f0930e6
fixed error value vs reference
john-ko29 Sep 27, 2020
3ab1007
flash card complete
john-ko29 Sep 28, 2020
ca47321
format attempted
john-ko29 Sep 29, 2020
8115958
frequency complete
john-ko29 Sep 30, 2020
c8e924e
generate attempted
john-ko29 Oct 1, 2020
89e6fa2
hitting the jackpot complete
john-ko29 Oct 2, 2020
79797c1
identical attempt
john-ko29 Oct 3, 2020
ca047f1
index multi complete
john-ko29 Oct 4, 2020
2fb3fc1
index shuffle complete
john-ko29 Nov 12, 2020
b43b1e5
joini two portion complete
john-ko29 Nov 13, 2020
4cc5d14
largest swap complete
john-ko29 Nov 14, 2020
d48c7dd
pi to decimal complete
john-ko29 Nov 15, 2020
a59f103
puzzle piece complete
john-ko29 Nov 16, 2020
bbf0bc0
repeating letter done
john-ko29 Nov 17, 2020
8b2366a
factorial complete
john-ko29 Nov 18, 2020
ea91461
highest and lowest complete
john-ko29 Nov 19, 2020
3bad750
attempted secret name
john-ko29 Nov 20, 2020
33e9ead
attempted secret name
john-ko29 Nov 21, 2020
62f3bde
snail
john-ko29 Nov 22, 2020
4d02dab
snail
john-ko29 Nov 23, 2020
05699f4
spell complete
john-ko29 Nov 24, 2020
f65be58
spell complete
john-ko29 Nov 25, 2020
571f81c
sum of all evens
john-ko29 Nov 26, 2020
5527307
sum of all evens
john-ko29 Nov 27, 2020
66d8c47
sum of cube
john-ko29 Nov 28, 2020
ccc588c
sum of cube
john-ko29 Nov 29, 2020
fa95c52
transform no dup
john-ko29 Nov 30, 2020
3259c61
transform no dup
john-ko29 Dec 1, 2020
6af7123
transform no dup
john-ko29 Dec 2, 2020
ccca955
upvote
john-ko29 Dec 3, 2020
b6e413e
upvote
john-ko29 Dec 3, 2020
e0ad169
upvote
john-ko29 Dec 4, 2020
ff0164e
upvote
john-ko29 Dec 5, 2020
00c5463
upvote
john-ko29 Dec 6, 2020
d94bbac
upvote
john-ko29 Dec 7, 2020
56dc00f
upvote
john-ko29 Dec 8, 2020
0877d54
upvote
john-ko29 Dec 9, 2020
5989d09
write function
john-ko29 Dec 10, 2020
be629c4
write function
john-ko29 Dec 11, 2020
ac7f610
write function
john-ko29 Dec 12, 2020
a4e5485
write function
john-ko29 Dec 13, 2020
1f68b98
pairs sums
john-ko29 Dec 14, 2020
e46b92b
pairs sums
john-ko29 Dec 15, 2020
4152f16
pairs sums
john-ko29 Dec 16, 2020
2c276bb
pairs sums
john-ko29 Dec 17, 2020
332bf42
pairs sums
john-ko29 Dec 18, 2020
ced3764
pairs sums
john-ko29 Dec 19, 2020
702829c
pairs sums
john-ko29 Dec 20, 2020
e01339e
pairs sums
john-ko29 Dec 20, 2020
21fae2b
pairs sums
john-ko29 Dec 21, 2020
a91d558
pairs sums
john-ko29 Dec 22, 2020
09062b9
pairs sums
john-ko29 Dec 23, 2020
39e9ec2
beginning and end pairs
john-ko29 Dec 31, 2020
0bc448b
beginning and end pairs
john-ko29 Jan 1, 2021
f5d8f47
beginning and end pairs
john-ko29 Jan 2, 2021
2f76a72
beginning and end pairs
john-ko29 Jan 3, 2021
97e78cc
beginning and end pairs
john-ko29 Jan 3, 2021
250ec30
beginning and end pairs
john-ko29 Jan 4, 2021
ddcb410
beginning and end pairs
john-ko29 Jan 5, 2021
45ccd20
beginning and end pairs
john-ko29 Jan 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion easy/index-shuffle/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
function indexShuffle(str) {
// Your code here.
let evenIndex = "";
let oddIndex = "";
for (let i = 0; i < str.length; i++) {
if (i % 2 === 0) {
evenIndex += str[i];
} else {
oddIndex += str[i];
}
}
return evenIndex + oddIndex;
}

module.exports = indexShuffle;
8 changes: 7 additions & 1 deletion easy/join-two-portions-of-a-path/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
function joinPath(portion1, portion2) {
// Your code here.
if (portion1[portion1.length - 1] === "/" && portion2[0] === "/") {
return portion1.substr(0, portion1.length - 1) + portion2;
} else if (portion1[portion1.length - 1] === "/" || portion2[0] === "/") {
return portion1 + portion2;
} else {
return portion1 + "/" + portion2;
}
}

module.exports = joinPath;
8 changes: 7 additions & 1 deletion easy/largest-swap/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
function largestSwap(num) {
// Your code here.
const oneDigit = num % 10;
const tenDigit = Math.floor(num / 10);
if (oneDigit > tenDigit) {
return false;
} else {
return true;
}
}

module.exports = largestSwap;
3 changes: 2 additions & 1 deletion easy/pi-to-n-decimal-places/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function myPi(n) {
// Your code here.
const pi = 3.141592653589793;
return parseFloat(pi.toFixed(n));
}

module.exports = myPi;
12 changes: 11 additions & 1 deletion easy/puzzle-pieces/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
function puzzlePieces(a1, a2) {
// Your code here.
if (a1.length !== a2.length) {
return false;
}
const fit = a1[0] + a2[0];
for (let i = 1; i < a1.length; i++) {
const currentPiece = a1[i] + a2[i];
if (fit !== currentPiece) {
return false;
}
}
return true;
}

module.exports = puzzlePieces;
7 changes: 6 additions & 1 deletion easy/repeating-letters/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
function doubleChar(str) {
// Your code here.
let doubleStr = "";
for (let i = 0; i < str.length; i++) {
doubleStr += str[i];
doubleStr += str[i];
}
return doubleStr;
}

module.exports = doubleChar;
6 changes: 5 additions & 1 deletion easy/return-the-factorial/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
function factorial(int) {
// Your code here.
let total = 1;
for (let i = 1; i < int; i++) {
total *= i;
}
return total;
}

module.exports = factorial;
11 changes: 10 additions & 1 deletion easy/return-the-highest-and-lowest-numbers/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
function highLow(str) {
// Your code here.
const numbers = str.split(" ")
let highest = parseInt(numbers[0])
let lowest = parseInt(numbers[0])
for (let i = 0; i < numbers.length; i++) {
if (highest < parseInt(numbers[i])) {
highest = parseInt(numbers[i]);
}
if (lowest > parseInt(numbers[i])) lowest = parseInt(numbers[i])
}
return highest + " " + lowest;
}

module.exports = highLow;
13 changes: 12 additions & 1 deletion easy/secret-society/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
function societyName(friends) {
// Your code here.
let name = "";
const initals = [];
for (let i = 0; i < friends.length; i++) {
initals.push(friends[i][0]);
}
initals.sort();

for (let i = 0; i < initals.length; i++) {
name += initals[i]
}

return name;
}

module.exports = societyName;
18 changes: 17 additions & 1 deletion easy/snail-race/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
function mauriceWins(mSnails, sSnails) {
// Your code here.
let wins = 0;

if (mSnails[0] > sSnails[2]) {
wins++;
}
if (mSnails[1] > sSnails[0]) {
wins++
}
if (mSnails[2] > sSnails[1]) {
wins++
}

if (wins >= 2) {
return true;
} else {
return false;
}
}

module.exports = mauriceWins;
7 changes: 6 additions & 1 deletion easy/spelling-it-out/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
function spelling(str) {
// Your code here.
const arr = [];
for (let i = 0; i < str.length; i++) {
arr.push(str.substr(0, i))
}

return arr;
}

module.exports = spelling;
11 changes: 10 additions & 1 deletion easy/sum-of-all-evens-in-a-matrix/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
function sumOfEvens(arr) {
// Your code here.
let evenTotal = 0;
for (let i = 0; i < arr.length; i++) {
for (let k = 0; k < arr[i].length; k++) {
if (arr[i][k] % 2 === 0) {
evenTotal += arr[i][k];
}
}
}

return evenTotal;
}

module.exports = sumOfEvens;
8 changes: 7 additions & 1 deletion easy/sum-of-cubes/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
function sumOfCubes(nums) {
// Your code here.
let total = 0;
for (let i = 0; i < nums.length; i++) {
let cube = Math.cube(nums[i])
total += cube;
}

return total;
}

module.exports = sumOfCubes;
11 changes: 10 additions & 1 deletion easy/transform-into-an-array-with-no-duplicates/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
function set(arr) {
// Your code here.
const obj = {};
const newArr = [];
for (let i = 0; i < arr.length; i++) {
if (!obj.hasOwnProperty(arr[i])) {
obj[arr[i]] = arr[i]
newArr.push(arr[i])
}
}

return newArr;
}

module.exports = set;
13 changes: 12 additions & 1 deletion easy/transform-upvotes/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
function transformUpvotes(str) {
// Your code here.
const arr = [];
const strArr = str.split(" ");
for(let i = 0; i < strArr.length; i++) {
if (strArr[i].indexOf("k") !== -1) {
let newNum = strArr[i].replace(/k/g, "");
let convertNum = parseFloat(newNum);
let trueNumber = convertNum * 1000;
arr.push(trueNumber);
}
}

return arr;
}

module.exports = transformUpvotes;
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
function factorial(x) {
// Your code here.
let total = 1;
for (let i = 2; i < x; i++) {
total *= i;
}

return total;
}

module.exports = factorial;
18 changes: 17 additions & 1 deletion hard/all-pairs-that-sum-to-target/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
function allPairs(arr, target) {
// Your code here.
const newArr = []
for (let i = 0; i < arr.length - 1; i++) {
for (let k = i + 1; k < arr.length ; k++) {
if (arr[i] + arr[k] === target) {
const tempArr = [];
if (arr[i] > arr[k]) {
tempArr.push(arr[k]);
tempArr.push(arr[i]);
} else {
tempArr.push(arr[i]);
tempArr.push(arr[k]);
}
newArr.push(tempArr);
}
}
}
return newArr;
}

module.exports = allPairs;
18 changes: 17 additions & 1 deletion hard/beginning-and-end-pairs/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
function pairs(arr) {
// Your code here.
const newArr = [];
let arrHalf = null;
if (arr.length % 2 === 0) {
arrHalf = arr.length / 2;
} else {
arrHalf = (arr.length - 1) / 2;
}

for (let i = 0; i < arrHalf; i++) {
const tempArr = [];
tempArr.push(arr[i]);
tempArr.push(arr[arr.length - (i + 1)])
newArr.push(tempArr);
}
return newArr;
}



module.exports = pairs;
14 changes: 13 additions & 1 deletion medium/a-pirate-s-tale/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
function numberOfDays(coordinate) {
// Your code here.
let days = 0;
let daysTaken = 0;
for (let i = 0; i < coordinate.length; i++) {
if (coordinate[i] !== 0) {
if (days === 5) {
days = 0;
continue;
}

days++
}
}
return daysTaken;
}

module.exports = numberOfDays;
8 changes: 7 additions & 1 deletion medium/accumulating-product/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
function accumulatingProduct(arr) {
// Your code here.
let accumulate = 0;
const newArray = [];
for (let i = 0; i < arr.length; i++) {
accumulate *= arr[i];
newArray.push(accumulate);
}
return newArray;
}

module.exports = accumulatingProduct;
13 changes: 12 additions & 1 deletion medium/algebra-sequence-boxes/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
function boxSeq(step) {
// Your code here.
let currentNumber = 0;
if (step === 0) {
return currentNumber;
}
for(let i = 1; i <= step; i++) {
if (i % 2 === 1) {
currentNumber += 3
} else {
currentNumber -= 1;
}
}
return currentNumber;
}

module.exports = boxSeq;
29 changes: 28 additions & 1 deletion medium/all-about-strings/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
function allAboutStrings(str) {
// Your code here.
const arr = [];
const letters = [];
let repeat = false;
arr.push(str.length);
arr.push(str.substring(0, 1));
arr.push(str.substring(str.length - 1));
if(str.length % 2 === 1) {
arr.push(str.substr((str.length - 1) / 2, 1))
} else {
arr.push(str.substr(((str.length - 1) / 2), 2))
}

for (let i = 0; i < str.length; i++) {
if (letters.includes(str[i])) {
arr.push(`@ index ${i}`)
repeat = true;
break;
} else {
letters.push(str[i])
}
}

if (!repeat) {
arr.push("not found");
}

console.log(arr)
return arr;
}

module.exports = allAboutStrings;
11 changes: 10 additions & 1 deletion medium/alternating-caps/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
function alternatingCaps(str) {
// Your code here.
let word = ""
for (let i = 0; i < str.length; i++) {
const letter = str[i];
if (i % 2 === 0) {
word += letter.toUpperCase();
} else {
word += letter.toLowerCase();
}
}
return word;
}

module.exports = alternatingCaps;
Loading