Mohd Talib

Mohd Talib

  • NA
  • 83
  • 696

Write a function to generate a series of random numbers.

Jun 3 2019 3:37 AM
Generate some events
  • Write a function to generate a series of random numbers. The function should print a random number between 1 and 1000 every 1 second.

    function generateTerms ()
    {
    // your code here that prints a random number every second
    }
  • Implement a callback
    Extend the generateTerms function in step 1 to call a supplied callback with the generated random number every second. Test the callback by making it do the printing task
    function generateTerms (callback)
    {
     // your code here that calls the supplied callback with a random number every second
    }
    function callback(term)
    {
     // your code here that prints the term
     }
     generateTerms(callback)
  • Print a running count
    Extend the callback to count and print a running count of the incoming terms
  • Print a running average
    Extend the callback to compute and print a running average of the incoming terms
  • Print a running standard deviation
    Extend the callback to compute and print a running standard deviation of the incoming terms.

Answers (5)