Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #11

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Main #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 62 additions & 20 deletions candidate-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,88 @@ const input = require('readline-sync');
// TODO 2: modify your quiz app to ask 5 questions //

// TODO 1.1a: Define candidateName //
let candidateName;
let candidateName = "";
// TODO 1.2a: Define question, correctAnswer, and candidateAnswer //
let question;
let correctAnswer;
let candidateAnswer;
let question = "Who was the first American woman in space? ";
let correctAnswer = "Sally Ride";
let candidateAnswer= '';


//TODO: Variables for Part 2
let questions;
let correctAnswers;
let candidateAnswers;

let questions = ["1. Who was the first American woman in space?", "2. True or False: 5 kilometer === 5000 meters", "3. (5 + 3)/2 * 10 = ? :", "4. Given the array [8, 'Orbit', 'Trajectory', 45], what is at index 2?", "5. What is the minimum crew size for the ISS?"];
let correctAnswers = ["Sally Ride", 'true', "40", 'Trajectory', "3" ];
let candidateAnswers = [];

for (let i = 0; i < questions.length; i++) {
console.log(questions[i]);
}
function askForName() {
// TODO 1.1b: Ask for candidate's name //

const input = require('readline-sync');
let candidateName = input.question("What is your name?");
}

function askQuestion() {
// TODO 1.2b: Ask candidate the question and assign the response as candidateAnswer //

const input = require("readline-sync");
let candidateAnswer = input.question(question);

}

function gradeQuiz(candidateAnswers) {
function gradeQuiz(candidateAnswers) {
let score = [`0, 20, 40, 60, 80`];
if (candidateAnswers === score[0]) {
console.log('You have 0/5 questions correct.');
return score[0];
} else if (candidateAnswers === score[1]) {
console.log('You have 1/5 questions correct.');
return score[1];
} else if (candidateAnswers === score[2]) {
console.log('You have 2/5 questions correct.');
return score[2];
} else if (candidateAnswers === score[3]) {
console.log('You have 3/5 questions correct.');
return score[3];
} else if (candidateAnswers === score[4]) {
console.log('You have 4/5 questions correct.');
return score[4];
} else if (candidateAnswers === score[5]) {
console.log('You have 5/5 questions correct.');
return score[5]

}; return gradeQuiz();


}

// TODO 1.2c: Let the candidate know if they have answered the question correctly or incorrectly //



let grade; //TODO 3.2 use this variable to calculate the candidates score.


return grade;
if (candidateAnswer === correctAnswer) {
console.log("Your answer is correct.")
} else {
console.log("Your answer is incorrect.");
}


let grade = (score / 5) * 100; //TODO 3.2 use this variable to calculate the candidates score.

if (grade == 100) {
return 100
} if (grade == 80) {
return 80
} if (grade == 60) {
return 60
} if (grade == 40) {
return 40
} if (grade == 20) {
return 20
} if (grade == 0) {
return 0
}

function runProgram() {

askForName();
// TODO 1.1c: Greet candidate using their name //
console.log();
console.log('Hello,'+ candidateName);
askQuestion();
gradeQuiz(this.candidateAnswers);
}
Expand Down
12 changes: 12 additions & 0 deletions lcprojects.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"githubPullRequests.ignoredPullRequestBranches": [
"main"
]
}
}
Loading