Topics: Functions as Data, Functions as Parameters
Project Title: Functions Benchmark
- Open VS Code and create a html file with your name like john.html
- Add current code to that file:
<!DOCTYPE html> <html> <body> <script> // your code here </script> </body> </html>
repeat(func, param, times)that takes a function
func, a paramter for the function
paramand number of calls
times. It should call the function with that parameter for requested times and log run number into console.
repeatDuration(repeat, times, func, param)that takes a repeat function
repeat, times of calling
times, function to be called
funcand parameters to this function
param. It should call the function and log its running time in milliseconds.
factorialthat gets a number and return its factorial and logs it into console.
Call repeatDuration to log running time of
factorialfor parameter 20 for 1000 times.
Want to get reviewed?
Send Pull Request. Check how to deliver your code: https://codingwithbasir.com/how-to-deliver-projects/