JSFiddle - React, Tailwind, and code Playground
by rexonms
JavaScript
// Closures
// Closure is when a fucntion remember and still have acces to it's variables even when in different scope.
const addTwoNumbers = (x,y) => addNumbers = (y) => x + y
const addTen = addTwoNumbers(10)
const addTwenty = addTwoNumbers(20)
console.log(addTen(10))
console.log(addTwenty(20))
const spitName = (name) => nameIs = () => `My name is ${name}`
const rex = spitName('rex')
const lina = spitName('lina')
console.log(rex())
console.log(lina())
const tx = 'what\'s my name'
console.log(tx.split('').reverse().join(''))