SHARE
TWEET

Untitled

a guest Feb 18th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Welcome to your first assignment.
  2. // Add your code here. You can do it!
  3.  
  4. let canidatesName;
  5. let quizQuestion = ['True or false: 5000 meters = 5 kilometers', '(5 + 3)/2 * 10 = ?', 'Given the array [8, "Orbit", "Trajectory", 45], what entry is at index 2?', 'Who was the first American woman in space?', 'What is the minimum crew size for the International Space Station (ISS)?'];
  6. let correctAnswer = ['true', '40', 'trajectory', 'Sally Ride', '3'];
  7. let canidatesAnswer;
  8.  
  9. const input = require('readline-sync');
  10. canidatesName = input.question('Canidate Name: ');
  11.  
  12. //canidatesAnswer = input.question(quizQuestion);
  13. //if (canidatesAnswer === correctAnswer){
  14. //  console.log(`Great job ${canidatesName}, ${correctAnswer} is correct!`);
  15. //}else{
  16. //  console.log(`That is incorrect, ${canidatesName}. the correct answer is ${correctAnswer}.`);
  17. //}
  18.  
  19. i = 0;
  20. grade = 0;
  21. questionNumber = 1;
  22. while (i < quizQuestion.length){
  23.   canidatesAnswer = input.question(`${questionNumber}) ${quizQuestion[i]}`);
  24.   if (canidatesAnswer.toLowerCase() == correctAnswer[i].toLowerCase()){
  25.     grade ++;
  26.     }else{
  27.     }
  28. console.log(`Your answer: ${canidatesAnswer} \nCorrect answer: ${correctAnswer[i]}\n`);
  29.   i++;
  30.   questionNumber++;
  31.  }
  32. percentage = (grade/5*100);
  33. console.log(`>>> Overall Grade: ${percentage}% ${grade} of 5 responses correct <<<`);
  34.  
  35. if (percentage >= 80){
  36.   console.log('>>> Status: PASSED <<<');
  37. }else{
  38.   console.log('>>> Status: FAILED <<<')
  39. }
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