This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function truncateString(str, num) { | |
if (num <= 3) { | |
str = str.slice(0, num) + "..."; | |
} else if (str.length > num) { | |
str = str.slice(0, (num - 3)) + "..."; | |
} | |
return str; | |
} | |
truncateString("Jason", 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function confirmEnding(str, target) { | |
var fragCount = target.length, | |
chunk = str.substring(str.length - fragCount); | |
if (chunk === target) { | |
return true; | |
} else { return false; } | |
} | |
confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var count = 0; | |
function cc(card) { | |
switch (card) { | |
case 2: | |
case 3: | |
case 4: | |
case 5: | |
case 6: | |
count++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function largestOfFour(arr) { | |
for (var i = 0; i < arr.length; i++) { | |
for (var j = 0; j < arr[i].length; j++) { | |
arr[i] = Math.max(...arr[i]); | |
} | |
} | |
return arr; | |
} | |
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var endArr = [], | |
firstCap = [], | |
finalStr = []; | |
function theChopper(arr) { | |
for (var i = 0; i < arr.length; i++) { | |
firstCap.push(arr[i].charAt(0).toUpperCase()); | |
endArr.push(arr[i].slice(1)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findLongestWord(str) { | |
var strArray = str.split(" "), | |
arrCount = []; | |
for (var i = 0; i < strArray.length; i++) { | |
arrCount.push(strArray[i].length); | |
} | |
return Math.max(...arrCount); | |
} | |
findLongestWord("The quick brown fox jumped over the lazy dog"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const SALESTAX = .0975, | |
PHONE_PRICE = 200.00, | |
ACCESS_PRICE = 40.00; | |
var ba = prompt("How much money you got?"), | |
ac = prompt("When to stop buying accessories?"), | |
bankAccount = parseInt(ba), | |
accessoryLimit = parseInt(ac), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverseString(str) { | |
var strArray = str.split(""); | |
strArray.reverse(""); | |
return strArray.join(""); | |
} | |
reverseString("hello"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = { | |
"2548": { | |
"album": "Slippery When Wet", | |
"artist": "Bon Jovi", | |
"tracks": [ | |
"Let It Rock", | |
"You Give Love a Bad Name" | |
] | |
}, | |
"2468": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function factorialize(num) { | |
var facArray = []; | |
if (num === 0) { | |
return 1; | |
} else { | |
for (var i = 1; i <= num; i++) { | |
facArray.push(i); |