const posts = [
{id: 1, upVotes: 2},
{id: 2, upVotes: 89},
{id: 3, upVotes: 1}
];
const totalUpVotes = posts.reduce((acc, curr)=>{
return acc + curr.upVotes
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 params = {id: '1', name: 'foo', isAcive: false}; | |
const query = '?' + Object.keys(params) | |
.map(param => | |
encodeURIComponent(param) + '=' + encodeURIComponent(params[param]) | |
) | |
.join('&'); | |
console.log (query) // ?id=1&name=foo&isAcive=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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Layout Markup</title> | |
</head> |
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 console=(function(oldCons){ | |
logMethod = function(color, msg){ | |
oldCons.log('%c' + msg , 'color:' + color); | |
} | |
return { | |
violet: function(msg){ | |
logMethod("#9400D3", msg) | |
}, | |
indigo: function(msg){ |
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 console=(function(oldCons){ | |
return { | |
log: function(){ | |
oldCons.log('%c' + "[ " + arguments.callee.caller.name + " method ]", 'background: #222; color: #bada55', arguments[0]); | |
} | |
}; | |
}(window.console)); | |
window.console = console; |
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
/* | |
Stack is a linear data structure which follows a particular order in which the operations are performed. | |
The order may be LIFO(Last In First Out) or FILO(First In Last Out). | |
Mainly the following three basic operations are performed in the stack: | |
Push: Adds an item in the stack. | |
Pop: Removes an item from the stack. The items are popped in the reversed order in which they are pushed. | |
If the stack is empty, then it is said to be an Underflow condition. |
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
/* | |
ExpressionMatcher is take the str parameter being passed | |
and return "Expression Matched" or "Expression Not Matched" | |
@param {string} str | |
@param {array} openExpArr <optional> | |
default value ['[', '{', '('] | |
@param {array} closeExpArr <optional> | |
default value [')', '}', ']'] | |
@returns |
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
/* | |
ReverseString(str) take the str parameter being passed and return the string in reversed order. | |
For example: if the input string is "Hello World and Coders" | |
then your program should return the string sredoC dna dlroW olleH. | |
*/ | |
const ReverseString = (str) => { | |
let reversedString = ""; | |
for (let i = str.length - 1 ; i >= 0; i--) { | |
reversedString = reversedString + str[i] |
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
/* | |
VowelCount is javascript function which takes string as input | |
return count of vowels available or 0 if no vowels available | |
*/ | |
const VowelCount = (str) =>{ | |
const vowelArray = ['a', 'e', 'i', 'o', 'u']; | |
let counter = 0; | |
for (let i = 0; i < vowelArray.length; i++) { | |
for (let j = 0; j < str.length; j++) { |