Skip to content

Instantly share code, notes, and snippets.

@raysubham
Last active October 12, 2023 09:36
Show Gist options
  • Save raysubham/056e8cdd4ac9134b15bb08a409eedd35 to your computer and use it in GitHub Desktop.
Save raysubham/056e8cdd4ac9134b15bb08a409eedd35 to your computer and use it in GitHub Desktop.
caching function
// Implement a caching function
const addNumbers = (a, b) => {
for (let i = 0; i < 1000000000; i++) {
// Do nothing
}
return a + b;
};
console.time("First time");
console.log(addNumbers(1, 2));
console.timeEnd("First time");
console.time("Second time");
console.log(addNumbers(2, 1));
console.timeEnd("Second time");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment