Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Pressed by mortonfox
import assert from "assert";
function longPressed(text: string, typed: string): boolean {
return text != typed && new RegExp('^' + [...text].join('+') + '+$').test(typed);
}
console.log("Example:");
console.log(longPressed("alex", "aaleex"));
// These "asserts" are used for self-checking
assert.strictEqual(longPressed("alex", "aaleex"), true);
assert.strictEqual(
longPressed("welcome to checkio", "weeeelcome to cccheckio"),
true
);
assert.strictEqual(
longPressed("there is an error here", "there is an errorrr hereaa"),
false
);
assert.strictEqual(
longPressed("hi, my name is...", "hi, my name is..."),
false
);
console.log("Coding complete? Click 'Check Solution' to earn rewards!");
Dec. 9, 2022
Comments: