Last active
October 12, 2023 09:36
-
-
Save raysubham/056e8cdd4ac9134b15bb08a409eedd35 to your computer and use it in GitHub Desktop.
caching function
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
// 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