JAVASCRIPT PROGRAMMING PRACTICE
Description
Print Numbers with Remainder 3 When Divided by 7
• In Progress Easy
Helpful
Write a function that takes an array as input and prints numbers that
have a remainder of 3 when divided by 7
Input
The first line of input will contain an array.
Output
The Output Should be a single line containing an array which prints
the numbers with Remainder 3 When Divided by 7.
Explanation
Read an array as input and prints numbers from the array that have a
remainder of 3 when divided by 7.
For Example, in the input array [7, 17, 5, 45], the numbers with a
remainder of 3 when divided by 7 are 17 and 45.
Sample Input 1
[7, 17, 5, 45]
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');
let inputString = "";
process.stdin.on('data', function (inputStdin) {
inputString += inputStdin;
});
process.stdin.on('end', function () {
inputString = inputString.trim();
main();
});
function readLine() {
return inputString;
}
function main() {
let input = readLine();
let array = JSON.parse("[" + input + "]");
let result = [];
for (let i = 0; i < array.length; i++) {
if (array[i] % 7 === 3) {
result.push(array[i]);
}
}
console.log(result);
}