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 caesar(str, increment) { | |
const letters = 'abcdefghijklmnopqrstuvwxyz'; | |
return str | |
.toLowerCase() | |
.split('') | |
.map(c => { | |
const index = letters.indexOf(c); | |
if (index === -1) return c; | |
let newIndex = index + increment; | |
if (newIndex < 0) { |
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 notFunny() { | |
function s(fn = () => {}) { | |
return () => { | |
const fnStr = fn.toString(); | |
console.log(fnStr); | |
const keywords = ['console', 'debugger']; | |
if (!keywords.find(key => fnStr.includes(key))) | |
throw new Error(`Uncaught ReferenceError: ${fn.toString().slice(0, 10)} is not defined`); | |
fn(); | |
} |
NewerOlder