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
const keyImg = 'c9c70ab642fedb925db9bfb33b4f73f1'; | |
const b = document.getElementById('body'); | |
let btn = document.getElementById('btn-search'); | |
let input = document.getElementById('search'); | |
let section = document.getElementById('section'); | |
async function getImg(word) { | |
try { | |
const url = `https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=${keyImg}&tags=${word}&tag_mode=all&extras=url_h&format=json&nojsoncallback=1`; | |
const res = await fetch(url); |
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 isNaN(numberInQuestion) { | |
return 'NaN' === String(+numberInQuestion); | |
} |
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 sortString(str) { | |
return str.split('').sort().join(''); | |
} | |
function isAnagram(str1, str2) { | |
return sortString(str1) === sortString(str2); | |
} | |
console.log(isAnagram('кот', 'ток')) |
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
const palyndrome = 'laal'; | |
function reverseString(str) { | |
return Array.prototype.reduceRight.call(str, (acc, newElement) => | |
acc + newElement, ''); | |
} | |
function isPalyndrome(str) { | |
const length = str.length; | |
if (length === 0 || length === 1) { |
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
//[1, [2, [3, 4], 5], 6, [7]] | |
// -> | |
//[1, 2, 3, 4, 5, 6, 7] | |
function reducer(acc, newElement) { | |
if (Array.isArray(newElement)) { | |
return acc.concat(newElement.reduce(reducer, [])); | |
} else { | |
return acc.concat([newElement]); | |
} |
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
//[1, [2, [3, 4], 5], 6, [7]] | |
// -> | |
//[1, 2, 3, 4, 5, 6, 7] | |
const reducer = (acc, newElement) => { | |
if (Array.isArray(newElement)) { | |
return acc.concat(newElement.reduce(reducer, [])); | |
} else { | |
return acc.concat([newElement]); | |
} |
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 sum(firstArg, opt_argsStack) { | |
const argsStack = (opt_argsStack || []).concat([firstArg]); | |
const nextSum = nextArg => sum(nextArg, argsStack); | |
nextSum.valueOf = () => argsStack.reduce((a, b) => a + b); | |
return nextSum; | |
} | |
console.log(+sum(1)); | |
console.log(+sum(1)(2)); |
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 sum(allPreviousSum) { | |
var newFunction = function(newMember){return sum(allPreviousSum + newMember)} | |
newFunction.valueOf = function(){return allPreviousSum} | |
return newFunction; | |
} | |
console.log(sum(1) == 1); | |
console.log(sum(1)(2) == 3); | |
console.log(sum(1)(2)(3) == 6); | |
console.log(sum(1)(2)(3)(4) == 10); |
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
const Token = { | |
NUMBER: 1, | |
LEFT_PAREN: 2, | |
RIGHT_PAREN: 3, | |
PLUS: 4, | |
MINUS: 5, | |
DIVIDE: 6, | |
MULTIPLY: 7 | |
} |
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 quickSort(aInput, aLeftIndex, aRightIndex) { | |
if (aInput.length > 1) { | |
const delimeter = partition(aInput, aLeftIndex, aRightIndex); | |
if (aLeftIndex < delimeter - 1) { | |
quickSort(aInput, aLeftIndex, delimeter - 1); | |
} | |
if (delimeter < aRightIndex) { | |
quickSort(aInput, delimeter, aRightIndex); | |
} | |
} |
NewerOlder