Skip to content

Instantly share code, notes, and snippets.

@quetzaluz
Created May 29, 2020 01:10
Show Gist options
  • Save quetzaluz/3cda198e76a3977bee573d5667057900 to your computer and use it in GitHub Desktop.
Save quetzaluz/3cda198e76a3977bee573d5667057900 to your computer and use it in GitHub Desktop.

Interview: Science Questions

You will be writing one additional function to help analyze responses for a science quiz. You will then add a feature onto that function. Your interview will help guide you through this process. As a reminder, each response is represented as an object with the following keys:

  • question - the question that was asked, represented as a string.
  • response - the response that was given, represented as a string.
  • correct - whether or not the response was graded as correct, represented as a boolean.
  • isEssayQuestion - whether or not the response is an essay question, represented as a boolean.

Data for the entire month is stored in an array. For example:

[
  {
    question: 'What is the phase where chromosomes line up in mitosis?',
    response: 'Metaphase',
    isCorrect: true,
    isEssayQuestion: false
  },
  {
    question: 'What anatomical structure connects the stomach to the mouth?',
    response: 'Esophagus',
    isCorrect: true,
    isEssayQuestion: false
  },
  {
    question: 'What are lysosomes?',
    response: 'A lysosome is a membrane-bound organelle found in many animal cells. They are spherical vesicles that contain hydrolytic enzymes that can break down many kinds of biomolecules.',
    isCorrect: true,
    isEssayQuestion: true
  },
  {
    question: 'True or False: Prostaglandins can only constrict blood vessels.',
    response: 'True',
    isCorrect: false,
    isEssayQuestion: false
  }
];

While you can use the data above as an example, assume there might be more responses and that the responses may differ. You can assume that every response is an object with the correct keys, with each value having a matching type.

How to Complete the Prompts

Read each prompt below to learn more about the functions you need to write. Write all of your code in the index.js file in the designated space. Do not delete any of the existing code you have been given!

Prompt 1 : scoreQuiz

Write a function named scoreQuiz that takes two arguments:

  • an array of all of the responses for a given person
  • a decimal number representing the minimum score needed to pass the quiz

It should return a boolean value that represents whether or not the student passed the quiz.

For example:

scoreQuiz(responses, 0.8); //> false
scoreQuiz(responses, 0.75); //> true
scoreQuiz(responses, 0.7); //> true

Prompt 2 : scoreQuiz (extended)

Add the following feature to your scoreQuiz function:

If the second argument is undefined, less than or equal to 0, or greater than 1, return a string that says:

'Minimum score entered incorrectly. Please check your function arguments and try again.'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment