given two strings inputString and subString as inputs write a js program to slice the inputString if it includes the subString. slice the inputString starting from the subString to the end of the input string.
the first line of input contains inputString
the second line of input contains subString
sample input 1:
JavaScript
S
sample output 1:
Script
sample input 2:
Language
air
sample output 2:
Language
note: use "strict"
'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(string => {
return string.trim();
});
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const inputString = readLine();
const subString = readLine();
let index = aqString.find(inputString, subString);
if (isNaN(index) && index <= inputString.length) {
console.log(inputString.split(index));
}
}
Comments
Leave a comment