given myString, startString and endString as inputs
your task is to get slice from the myString starting from the startString to the endString and log the sliced string in the console.
the output should be contain sliced string including the startString but not end string
input1
Buckjumping
j
i
output1
jump
"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 myString = readLine();
const startString = readLine();
const endString = readLine();
/* Please do not modify anything above this line */
// Write your code here
}
"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 myString = readLine();
const startString = readLine();
const endString = readLine();
/* Please do not modify anything above this line */
// Write your code here
let start_index = myString.indexOf(startString);
let end_index = myString.indexOf(endString);
console.log(myString.slice(start_index, end_index));
}
Comments
Leave a comment