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
| DEL /F/Q/S *.* > NUL |
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
| const readings = [ | |
| { | |
| lat: '21.4', | |
| lng: '23.5', | |
| vehicle: 'sdkhf', | |
| id: '1' | |
| }, | |
| { | |
| lat: '22.4', | |
| lng: '25.5', |
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
| var firstWord = "Mary"; | |
| var secondWord = "Army"; | |
| console.log(isAnagram(firstWord, secondWord)); // true | |
| function isAnagram(first, second) { | |
| let a = first.toLowerCase(); | |
| let b = second.toLowerCase(); | |
| a = a.split("").sort().join(""); | |
| b = b.split("").sort().join(""); |
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 createBase(base){ | |
| return function(n){ | |
| return base + n; | |
| } | |
| } | |
| const addSix = createBase(6); | |
| console.log(addSix(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
| const g = n => { | |
| console.log("g", n); | |
| return n + 1 | |
| }; | |
| const f = n => { | |
| console.log("f", n); | |
| return n * 2; | |
| } |
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 typeOf(val){ | |
| return Object.prototype.toString.call(val); | |
| } |
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 reverseEachWord(str){ | |
| // Reversing String with Each word | |
| const reverseStr = str.split("").reverse().join(""); | |
| // Reversing String to Normal | |
| return reverseStr.split(" ").reverse().join(" "); | |
| } | |
| console.log(reverseEachWord("Welcome to this Javascript Guide!")); |
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
| var fields = ['firstName', 'lastName', 'email']; | |
| var oldVals = ['John', 'Doe', '[email protected]']; | |
| var newVals = ['Jo', 'Do', '[email protected]']; | |
| const object = function (array, keys1, keys2) { | |
| console.log(array) | |
| console.log(keys1) | |
| console.log(keys2) | |
| var r = {}; | |
| keys1.forEach(function (k1, i) { | |
| console.log(k1) |
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
| const obj = { | |
| name: "Rahul", | |
| job: "Software Engineer", | |
| age: 23, | |
| city: "Mumbai", | |
| hobby: "Reading books" | |
| }; | |
| const extract = (obj, ...keys) => { | |
| const newObject = Object.assign({}); | |
| Object.keys(obj).forEach((key) => { |
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
| // Solution 1: | |
| var myObject = { 'a': 1, 'b': 2, 'c': 3 }; | |
| Object.keys(myObject).map(function(key, index) { | |
| myObject[key] *= 2; | |
| }); | |
| console.log(myObject); | |
| // => { 'a': 2, 'b': 4, 'c': 6 } | |
| //==================================================================== | |
| //==================================================================== |
NewerOlder