Skip to content

Instantly share code, notes, and snippets.

@itsazzad
Forked from martinaglv/01.js
Created May 28, 2018 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsazzad/68cdc835b09c0f3e1d0c6e52c1e66d5e to your computer and use it in GitHub Desktop.
Save itsazzad/68cdc835b09c0f3e1d0c6e52c1e66d5e to your computer and use it in GitHub Desktop.
What do these functions do?
function whatDoesItDo(val){
return val ? 1 : 2;
}
function whatDoesItDo(param){
return { blue:"#0000ff", green:"#00ff00", red:"#ff0000" }[param];
}
function whatDoesItDo(color){
if (color !== 'blue' || color !== 'green') {
color = 'red';
}
return color;
}
function whatDoesItDo(arr){
return arr.filter(function(elem, pos) {
return arr.indexOf(elem) == pos;
});
};
function whatDoesItDo(arr){
return arr.reduce(function(s, n){ return s + n; }, 0);
}
function whatDoesItDo(arr){
return arr.map( function(x){ return x*2; });
}
function whatDoesItDo(mood){
return mood && "I like this" || "I don't like this";
}
function whatDoesItDo(str){
return str.split('').reverse().join('')
}
function whatDoesItDo(){
return document.querySelectorAll('*').length;
}
function whatDoesItDo(arr){
return Math.max.apply(null, arr);
}
function whatDoesItDo(arr){
return arr.slice(0).sort();
}
function whatDoesItDo(num){
return Math.max(0, Math.min(10, num));
}
function whatDoesItDo(){
var values = [];
myBlock: {
values.push('1');
values.push('2');
break myBlock;
values.push('3');
}
values.push('4');
return values.join(',');
}
function whatDoesItDo(){
return Array(4).join("lol" - 2) + " Batman!";
}
function whatDoesItDo(str){
return str.bold().italics();
}
function whatDoesItDo(str){
return /^\d{3,}$/.test(str);
}
function whatDoesItDo(num){
return this + num;
}
whatDoesItDo = whatDoesItDo.bind(10);
function whatDoesItDo(){
return (![]+[])[+[]]+(![]+[])[+!+[]]+
([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment