Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second Index solution in Uncategorized category for Second Index by Elena_Korljukova
import assert from "assert";
function secondIndex(text: string, symbol: string): number | undefined {
if (text.indexOf(symbol) >= 0 && text.indexOf(symbol) < text.length - 1){
var n = text.indexOf(symbol) + 1;
var x = text.slice(n).indexOf(symbol);
}
var z = x >=0 ? x + n : undefined;
return z;
}
console.log('Example')
console.log(secondIndex("sims", "s"))
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(secondIndex("sims", "s"), 3)
assert.equal(secondIndex("find the river", "e"), 12)
assert.equal(secondIndex("hi", " "), undefined)
assert.equal(secondIndex("hi mayor", " "), undefined)
assert.equal(secondIndex("hi mr Mayor", " "), 5)
console.log("You are awesome! All tests are done! Go Check it!");
June 10, 2020
Comments: