One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
var, let, and const. What are the differences of the three and which ones should you use? | |
If you do not know what let and const are, they are basically different variations of the “variable”, derived from ES6. | |
Variables are absolutely essential to any programming language, but in Javascript, the var keyword does has some flaws. | |
Thats where ES6 variables come in. | |
When you declare a const = Cannot be updated | |
When you declare a let = The variable can only be used in the block its created in |
'esversion: 6'; | |
function myReplace(str, before, after) { | |
var re = new RegExp(before); | |
return before[0] === before[0].toLowerCase() ? str.replace(re, after) | |
: str.replace(re, after.charAt(0).toUpperCase() + after.slice(1)); | |
} | |
myReplace("He is Sleeping on the couch", "Sleeping", "sitting"); |
'esversion: 6'; | |
function translatePigLatin(str) { | |
var vowels = ['a', 'e', 'i', 'o', 'u']; | |
var string = str.split(''); | |
var vowelFirst = false; | |
var vowelIndex; | |
vowels.map(vowel => vowel === str.charAt(0) ? vowelFirst = true : false); | |
for (var i = 0; i < string.length; i++) { |
'esversion: 6'; | |
function whatIsInAName(collection, source) { | |
// Stores the name of each nameValue pair of the source object in an array | |
var sourceKeys = Object.keys(source); | |
// Iterates through the collection array | |
return collection.filter(item => { | |
// For every key in the sourceKeys variable |
function diffArray(arr1, arr2) { | |
var sorted1 = arr1.filter(function(e){ | |
return this.indexOf(e) < 0; | |
}, arr2); | |
var sorted2 = arr2.filter(function(e){ | |
return this.indexOf(e) < 0; | |
}, arr1); | |
// Same, same; but different. | |
return sorted1.concat(sorted2); | |
} |