This file contains hidden or 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 testEqual(val) { | |
if (val == 12) { // Change this line | |
return "Equal"; | |
} | |
return "Not Equal"; | |
} | |
// Change this value to test | |
testEqual(10); |
This file contains hidden or 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
<head><link href="https://fonts.googleapis.com/css?family=Inconsolata:400,700" rel="stylesheet"> | |
</head> | |
<body> | |
<nav id="navbar"> | |
<header>FCC's RWD cert.</header> | |
<ul> | |
<a href="#Basic_HTML_and_HTML5" class="nav-link"><li>Basic HTML and HTML5</li></a> | |
<a href="#Basic_CSS" class="nav-link"><li>Basic CSS</li></a> | |
<a href="#Applied_visual_design" class="nav-link"><li>Applied visual design</li></a> |
This file contains hidden or 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
// Falsy bouncer | |
function bouncer(arr) { | |
return arr.filter(function(val) { | |
return Boolean(val) !== false; // Same as: return (val); | |
}); | |
} | |
bouncer([7, "ate", "", false, null, 9, NaN]); |
This file contains hidden or 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
// Mutations | |
function mutation(arr) { | |
var a = arr[0].toLowerCase(); | |
var b = arr[1].toLowerCase(); | |
for (i=0; i<b.length; i++){ | |
if (a.indexOf(b[i]) < 0){ | |
return false; | |
} |
This file contains hidden or 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 slasher(arr, howMany) { | |
return arr.slice(howMany); | |
/* With the splice() method: | |
arr.splice(0, howMany); | |
return arr; | |
*/ | |
/* Using loops: | |
var newarr = []; |
This file contains hidden or 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 chunkArrayInGroups(arr, size) { | |
var newarr=[]; | |
for (i=arr.length, y=0; i>0; i-=size, y+=size){ | |
newarr.push(arr.slice(y, size+y)); | |
} | |
/* Simpler using just one var but calculates arr.length on each iteration | |
for (i=0; i<arr.length; i+=size){ | |
newarr.push(arr.slice(i, i+size)); | |
}*/ |
This file contains hidden or 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) { | |
return str.substr(0, num) + '...'; | |
} | |
if (num >= str.length) { | |
return str; | |
} | |
return str.substr(0, num - 3) + '...'; | |
} |
This file contains hidden or 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 repeatStringNumTimes(str, num) { | |
if (num < 0){return "";} | |
var res=""; | |
for (i=num; i>0; i--){ | |
res+=str; | |
} | |
return res; | |
//Using recursion: return str + repeatStringNumTimes(str, num-1); | |
} |
This file contains hidden or 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) { | |
return str.substr(-target.length) === target; | |
// With the substring() method: return str.substring(str.length - target.length) === target; | |
// Using the endsWith() method: return str.endsWith(target); | |
} |
This file contains hidden or 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 (i=arr.length-1; i>=0; i--){ | |
arr[i] = Math.max.apply(null, arr[i]); // I was thinking on doing it with max and reduce buy this looks cleaner | |
// Using ES6's spread operator: 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]]); |