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 p = Promise.resolve().then(function() { | |
console.log('Promise resolve callback'); // Prints Promise resolve callback | |
}, function() { | |
console.log('Promise reject callback'); | |
}); |
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
git add . | |
git commit -m “adding few files” | |
git log --oneline | |
touch forgot.js // adds new file to the project | |
git add . // adds recently added file to the stagging | |
git commit --amend --no-edit // adds new file to the previous commit without changing the commit message | |
git log --oneline |
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
browser | |
.execute(function (url1, window1) { | |
window.open(url1, window1, "height=1024,width=768"); | |
}, [URL1, WINDOW1]); |
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 arr = ['javascript','css','html']; | |
function printSkill(element, index) { | |
console.log(element + ' is the ' + index + ' element in the array'); | |
} | |
arr.forEach(printSkill); |
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
// setter | |
localStorage.setItem("employeeName", "Ryan"); | |
localStorage.setItem("employeeId", 121456789); | |
// getter | |
var name = localStorage.getItem("employeeName"); // Ryan | |
var id = localStorage.getItem("employeeId"); // 121456789 |
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
git commit --soft <Last commit where HEAD should point> | |
git commit -m 'Many squashed commits' | |
git push --force origin master |
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'; | |
function braces(values) { | |
var i; | |
var result = []; | |
var len = values.length; | |
for (i = 0; i < len; i++) { | |
if (isBalanced(values[i])) { | |
result.push('YES'); |
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 deepCopy(oldObject) { | |
var temp = JSON.stringify(oldObject); | |
var newObject = JSON.parse(temp); | |
return newObject; | |
} | |
var employee1 = { | |
'name': 'Tony', | |
'age': 27, |
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 createAndInitialize2DArray(size) { | |
// catch a bug & fix me! | |
var defaultValue = 0; | |
var twoDimensionalArray = []; | |
function initOneDArray() { | |
var row = []; | |
for (var i = 0; i < size; i++) { | |
row.push(defaultValue); | |
} |
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 cachedNumbers = {}; | |
function calculateFibonacciSum (num) { | |
if(cachedNumbers[num]) { | |
return cachedNumbers[num]; | |
} | |
if(('number' === typeof num) && num <= 0) { | |
throw new Error ('Fibonnci series starts with 0. Please, enter any interget greater than or equal to 0'); | |
} | |
else if(('number' === typeof num) && num === 0) { |