Giter Site home page Giter Site logo

create-questions's Introduction

CreateQuestions Assignment


In this assignment, students are to add two more functions into their lib.js file. First, they will add a createPrompt function which expects an object with properties: numQuestions and numChoices and must return an array of objects in a specific format (listed in the CreatePrompt Format section below). The numQuestions parameter should have a default value of 1 and the numchoices parameter should have a default value of 2. Second, students will add createQuestions, which takes an object which has question numbers and choices as keys and returns an array of question objects which each contain a question and its corresponding choices. The object parameter should default to an empty object. The format of the array of questions objects is detailed in the CreateQuestion Format section below.

Goal


To challenge students to think more functionally through repetition of difficult problems which require them to think in ways they may not have before.

Tasks


  • Copy your chooseRandom function from the chooseRandom assignment into lib.js
  • Implement createPrompt using the given format below and the given test cases
  • Implement the createQuestions function based on the format below and provided tests
  • Ensure all tests are passing when you run the npm test command

CreatePrompt Format


createPrompt should return an array of objects in the following format:

[
  { // Questions are repeated numQuestion number of times
    type: 'input',
    name: `question-${(Question Number)}`,
    message: `Enter question ${(Question Number)}`
  },
  { // Choices are repeated numChoices number of times for each question
    type: 'input',
    name: `question-${(Question Number)}-choice-${(Choice Number)}`,
    message: `Enter answer choice ${(Choice Number)} for question ${(Question Number)}`
  },
  .
  .
  .
]

Example of createPromt({ numQuestions: 2, numChoices: 2 }):

[
  {
    type: 'input',
    name: `question-1`,
    message: `Enter question 1`
  },
  {
    type: 'input',
    name: `question-1-choice-1`,
    message: `Enter answer choice 1 for question 1`
  },
  {
    type: 'input',
    name: `question-1-choice-2`,
    message: `Enter answer choice 2 for question 1`
  },
  {
    type: 'input',
    name: `question-2`,
    message: `Enter question 2`
  },
  {
    type: 'input',
    name: `question-2-choice-1`,
    message: `Enter answer choice 1 for question 2`
  },
  {
    type: 'input',
    name: `question-2-choice-2`,
    message: `Enter answer choice 2 for question 2`
  },
]

CreateQuestions Format


createQuestions should return an array of question objects in the following format:

 [
  { // Repeated for the total number of questions
    type: 'list',
    name: (Question Name),
    message: (Question),
    choices: [ // Repeated for the total number of choices for each question
      (Choice-1)
      (Choice-2)
      (Choice-3)
      (Choice-4)
      .
      .
      .
    ]
  },
  .
  .
  .
]

Example of:

createQuestions({
  'question-1': 'Do you think you\'re ready for this?',
  'question-1-choice-1': 'Beyond ready!!!',
  'question-1-choice-2': 'Totally!',
  'question-2': 'Are you loving JS yet?',
  'question-2-choice-1': 'It\'s tubular!',
  'question-2-choice-2': 'Way rad man!'
})

Result:

[
  { // Repeated for the total number of questions
    type: 'list',
    name: 'question-1',
    message: 'Do you think you\'re ready for this?',
    choices: [
      'Beyond ready!!!',
      'Totally!'
    ]
  }, { // Repeated for the total number of questions
    type: 'list',
    name: 'question-2',
    message: 'Are you loving JS yet?',
    choices: [
      'It\'s tubular!',
      'Way rad man!'
    ]
  }
]

create-questions's People

Contributors

anubhawm avatar wmarttala avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.