Flattening & case conversion
the given code to get output using array methods flat(),map() and string methods toLowerCase() and toUpperCase().
input
the first line input is an array nestedArray
the second line input is a number depth
output
the output containing an array with words having even lengths in lowercase and odd length in uppercase
input1
['Inspector', ['ANKLE',['HIKE']],'pawn']
output2
['INSPECTOR','ANKLE', 'hike',' pawn']
function readLine() {
return inputString[currentLine++];
}
function main() {
const nestedArray = JSON.parse(readLine().replace(/'/g, '"'));
const depth = JSON.parse(readLine());
/* Please do not modify anything above this line */
// Write your code here
}
words with vowels
the goal of the code is to get output using array method filter()
input
the input will be single line containing an array wordsList
output
the output should be single line containing an array with filtered words
input1
['Sword', 'Myth', 'Patient' ,'Rhythm] output2
['Sword', 'Patient']
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const wordsList = JSON.parse(readLine().replace(/'/g, '"'));
const vowelsList = ["a", "e", "i", "o", "u"];
// Write your code here
}
the goal of this code is to quickly get you off the ground with the array method map().
input
the input will be single line containing an array myArray.
output
the output will be single line containing the newArray.
constaints
Strings should be given in quotes
input1
[ 1, 'David' 10, {'points':97}, 25, 'alphabet', true]
output1
[2, 'string' 20, 'object', 50, 'string', 'boolean']
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const myArray = JSON.parse(readLine().replace(/'/g, '"'));
// Write your code here
}
Bob a builder has come to you to build a program for his business. He needs to determine the square footage of a room in order to buy materials and calculate costs. Bob charges $125 per square metre. The program is going to ask the user to enter the name of a room. It will then ask for the width and length of the room (in meters) to be built. The program will calculate the room area and use this information to generate an approximate cost. Your program will display the room, the total area and the approximate cost to the screen.
Using Pseudocode, develop Javascript for this problem.
Double the numbers
the goal of this code is to get quickly off the ground with array method map().
input
output
constraints
sample input1
[1, 'David', 10, {'points':97}, 25, 'alphabet', true]
sample output1
[2, 'string' 20, 'object', 50, 'string' 'boolean']
function readLine() {
return inputString[currentLine++];
}
function main() {
const myArray = JSON.parse(readLine().replace(/'/g, '"'));
/* Please do not modify anything above this line */
// Write your code here
}
the goal of this code is to quickly get you off the ground with Creating and Consuming Promises.
input
output
based on inputs
sampleinput1
true
true
sampleoutput1
Taken Shower
Had Breakfast
Got to Work
function main() {
const isHotWaterReady = JSON.parse(readLine());
const isBreakfastReady = JSON.parse(readLine());
/* Please do not modify anything above this line */
// Write your code here
const takingShower = () => {
return new Promise((resolve,reject) => {
isHotWaterReady ? resolve("Taken Shower") : reject ("Hot Water Not Ready")
});
}
const breakFast = () => {
return new Promise((resolve,reject) => {
isBreakfastReady ? resolve("Had Breakfast") : reject ("Breakfast Not Ready")
});
}
the goal of this coding exam is to quickly get off you the ground with the array method every().
input
output
input1
[{'name': 'Blake Hodges', 'points':[76, 98, 88, 84]}
output1
['Blake Hodges]
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const candidatesList = JSON.parse(readLine().replace(/'/g, '"'));
// Write your code here
}
Bob a builder has come to you to build a program for his business. He needs to determine the square footage of a room in order to buy materials and calculate costs. Bob charges $125 per square metre. The program is going to ask the user to enter the name of a room. It will then ask for the width and length of the room (in meters) to be built. The program will calculate the room area and use this information to generate an approximate cost. Your program will display the room, the total area and the approximate cost to the screen.
WEB230 JavaScript 1 Assignment 3 - Quiz Average In this assignment we will write a JavaScript program to calculate the average of a set of quiz marks. Instructions 1. Create variable containing an array that will contain five or more numbers that represent the marks on quizzes. It is assumed that all quizzes will be out of 10 so the numbers must be values between 0-10. 2. Create a function that will take the array as an argument and return the average of the quizzes. 3. Output a text message with the values of the quizzes, space seperated without brackets. Use a template literal when constructing the output strings (AKA back-ticks, template literals are explained in the section on Strings in Chapter 1). 4. Output a text message with the final average rounded to one decimal place. Again use a teplate literal.
the goal of this code is quickly to get off the ground with classes.
given playerName, Nitro and speed are inputs write a super class Race with property and methods
inputs
outputs
sample input1
Alyssa
100
sample output1
Race has started
speed 50; Nitro 50
speed 70; Nitro 60
Alyssa is the winner
speed 0; Nitro 60
sample input2
Joel
100
100
sample output2
Race has started
speed 150; Nitro 50
speed 170; Nitro 60
Joel is the winner
speed 0; Nitro 60