String Slicing
Given two strings
function main() {
let inputString = readLine();
const subString = readLine();
/* Write your code here */
}
i want code in between write code here
const inputString = 'JavaScript';
const subString = 'S';
console.log(inputString)
console.log('Sample Input 1');
console.log(subString.substr(inputString.substr(subString)));
// expected output: "Script"
console.log('Sample Output 1');
const subString2 = 'Script';
console.log(subString2.substr(inputString.substr(subString2)));
console.log('Sample Input 2');
const inputString2 = 'Language';
const subString3 = 'air';
console.log(inputString2);
console.log(subString3);
// expected output: "Language"
if(inputString2.includes(subString3)) {
console.log('Sample Output 2');
console.log(subString3);
}else{
console.log('Sample Output 2');
console.log(inputString2)
}
Comments
Leave a comment