Topics: Functions as Data, Functions as Parameters
- 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>
-
Declare function
repeat(func, param, times)
that takes a functionfunc
, a paramter for the functionparam
and number of callstimes
. It should call the function with that parameter for requested times and log run number into console. -
Declare function
repeatDuration(repeat, times, func, param)
that takes a repeat functionrepeat
, times of callingtimes
, function to be calledfunc
and parameters to this functionparam
. It should call the function and log its running time in milliseconds. -
define function
factorial
that gets a number and return its factorial and logs it into console. -
Call repeatDuration to log running time of
factorial
for parameter 20 for 1000 times.
Send Pull Request. Check how to deliver your code: https://codingwithbasir.com/how-to-deliver-projects/
Download Learn JavaScript eBook from https://codingwithbasir.com/learn-javascript