by Abdul Rawoof A R Updated: Feb 25, 2023
Fig : Preview of the output that you will get on running this code from your IDE.
console.time ('add 1 million items') console.log ( Array.from (Array (1e6), (_,x) => x) .reduce ((x,y) => x + y, 0)) console.timeEnd ('add 1 million items') // 499999500000 // add 1 million items: 225ms console.time ('add 10 million items') console.log ( Array.from (Array (1e7), (_,x) => x) .reduce ((x,y) => x + y, 0)) console.timeEnd ('add 10 million items') // 49999995000000 // add 10 million items: 2537.070 ms
Follow the steps carefully to get the output easily.
- Save the file and run the file using run button to generate the output.
I hope you found this useful.
I tested this solution in the following versions. Be mindful of changes when working with other versions.
- The solution is created and tested in Visual Studio Code 1.74.1.
- Code Runner version v0.11.8.
- For any support on kandi solution kits, please use the chat
- For further learning resources, visit the Open Weaver Community learning page.