SHARE
TWEET

Untitled

a guest Feb 21st, 2020 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///potegowanie
  2. const numQuestions = 10;
  3. const maxNumber = 16;
  4. const minNumber = 1;
  5.  
  6. let numGoodAnswers = 0
  7.  
  8. function getRandomNumber() {
  9.     return Math.floor((Math.random() * maxNumber) + minNumber);
  10. }
  11.  
  12. for (let num = 0; num < numQuestions; num++) {
  13.     let firstNumber = 2;
  14.     let secondNumber = getRandomNumber();
  15.  
  16.     let result = firstNumber ** secondNumber;
  17.     let answer = prompt('How much is ' + firstNumber + ' ** ' + secondNumber + '?');
  18.  
  19.     if (result.toString() === answer) {
  20.         console.log('Good Answer')
  21.         numGoodAnswers++;
  22.     } else {
  23.         console.log('Bad Answer')
  24.     }
  25.     console.log('Number of correct answers so far:' + numGoodAnswers);
  26. }
  27.  
  28.  
  29. let percentResult = (numGoodAnswers / numQuestions) * 100;
  30. let result = (0, 50);
  31. let grade = 1;
  32. console.log(percentResult, result, grade)
  33. while (result <= 100 && percentResult >= result) {
  34.     grade++;
  35.     result = result += 10;
  36.     console.log(grade - 1, result - 10);
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top