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
// Complete the calculateArea function below. | |
// It returns a Promise which on success, returns area of the shape, and on failure returns [-1]. | |
let calculateArea = (shape, values) => { | |
const myShape = { | |
rectangle: (l, b) => { return (l * b) }, | |
square: (l) => { return (l * l) }, | |
circle: (r) => { return (3.14 * r * r) }, | |
triangle: (b, h) => { return (b * h / 2) } | |
}; | |
return new Promise((resolve, reject) => { |
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 anagram(str) { | |
let arr = str.split(''); | |
let anaResult, anaValue, response; | |
let finalArr = []; | |
for (let index = 0; index < arr.length; index++) { | |
let cleanNewArray = []; | |
let result = true | |
let resultArr = []; | |
let compare = arr[index]; | |
for (let index = 0; index < arr.length; index++) { |
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 frankenSplice(arr1, arr2, n) { | |
let arr3 = []; | |
arr2.splice(n, 0, arr1) | |
arr2 | |
arr3 = arr2.join(","); | |
console.log(arr3.length); | |
} |
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 titleCase(str) { | |
let finalArr = []; | |
let finalString = ""; | |
let lowstr = str.toLowerCase(); | |
let spltsstr = lowstr.split(" "); | |
for (let count = 0; count < spltsstr.length; count++) { | |
let newstr = spltsstr[count] | |
let spltstr = newstr.split(""); | |
let result = spltstr[0].toUpperCase(); | |
for (let index = 1; index < spltstr.length; index++) { |
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 (str.length <= num) { | |
console.log(str); | |
return str; | |
} else { | |
var newStr = []; | |
var nstr = str.split(""); | |
for (let index = 0; index < num; index++) { |