JS Essentials CODING TEST 2 Answers
JS Essentials CODING TEST 2 Answers
1.Car Race
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
function readLine() {
return inputString[currentLine++];
}
// Create your Super Class Race and Sub Class Car here
class Race{
constructor(playerName){
this.playerName=playerName;
// this.nitro=nitro;
// this.speed=speed;
}
startRace(){
return "Race has started";
}
endRace(){
return `${this.playerName} is the winner`;
}
}
class Car extends Race{
constructor(playerName,nitro,speed){
super(playerName);
this.nitro=nitro;
this.speed=speed;
}
applyBreak(){
return this.speed=0;
}
nitroBoost(){
return this.speed+=50, this.nitro-=50;
}
accelerate(){
return this.nitro+=10, this.speed+=20;
}
}
function main() {
const playerName = readLine();
const nitro = JSON.parse(readLine());
const speed = JSON.parse(readLine());
const car1 = new Car(playerName, nitro, speed);
console.log(car1.startRace());
car1.nitroBoost();
console.log(`Speed ${car1.speed}; Nitro ${car1.nitro}`);
car1.accelerate();
console.log(`Speed ${car1.speed}; Nitro ${car1.nitro}`);
console.log(car1.endRace());
car1.applyBreak();
console.log(`Speed ${car1.speed}; Nitro ${car1.nitro}`);
}
2.Double the Numbers
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
function readLine() {
return inputString[currentLine++];
}
function main() {
const myArray = JSON.parse(readLine().replace(/'/g, '"'));
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
function readLine() {
return inputString[currentLine++];
}
function main() {
const wordsList = JSON.parse(readLine().replace(/'/g, '"'));
const vowelsList = ["a", "e", "i", "o", "u"];
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
function readLine() {
return inputString[currentLine++];
}
function main() {
const nestedArray = JSON.parse(readLine().replace(/'/g, '"'));
const depth = JSON.parse(readLine());
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
function readLine() {
return inputString[currentLine++];
}
function main() {
const wordsList = JSON.parse(readLine().replace(/'/g, '"'));
const myString = readLine();
}
}
console.log(newWordsList)
}
6. Bunty Birthday
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
function readLine() {
return inputString[currentLine++];
}
function main() {
const birthdaysList = JSON.parse(readLine().replace(/'/g, '"'));
const buntyBirthday = new Date("2000-06-13");
console.log(result.years);
}
FOLLOW CODING SOLUTIONS YOUTUBE CHANNEL TO GET
ANSWERS FOR ALL ASSIGNMENTS AND CODING TESTS
https://www.youtube.com/channel/UCxQ3ohi9sLWrGhMmxnI
270w