I want to pass all test cases
Sample Output 1
Item Found
Sample Output 2
Category Not Found
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 categoryOfItem = readLine();
const item = readLine();
const mart = [
{
category:"pulses",
items: ["green gram", "green peas", "Turkish gram"]
},
{
category:"soaps",
items:["santoor", "dove", "lux", "pears"]
},
];
}
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 categoryOfItem = readLine();
const item = readLine();
const mart = [
{
category:"pulses",
items: ["green gram", "green peas", "Turkish gram"]
},
{
category:"soaps",
items:["santoor", "dove", "lux", "pears"]
},
];
let found = false;
for (int i = 0; i < mart.length; i++) {
if (item === mart.category)
found = true;
}
if (found)
console.log("Item Found")
else
console.log("Category Not Found")
}
Comments
Leave a comment