JSFiddle - React, Tailwind, and code Playground

JavaScript

function add(a, b) {
  if (add.cache === undefined) add.chache = {};


  if (add.chache[`${a} ${b}`]) {
    console.log(add.cache);
    return add.cache[`${a} ${b}`];
  } else {
    console.log(add.cache);
    add.cache[`${a} ${b}`] = a + b;
    return add.cache[`${a} ${b}`];
  }
}

add(1, 2);