Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Acceptable Password III by freeman_lex
// Taken from mission Acceptable Password II
// Taken from mission Acceptable Password I
import assert from "assert";
function isAcceptablePassword(password: string): boolean {
const cond1 = password.length > 6;
const cond2 = /\d/.test(password);
const cond3 = /\D/.test(password);
return [cond1, cond2, cond3].every((x) => x === true);
}
console.log("Example:");
console.log(isAcceptablePassword("short"));
// These "asserts" are used for self-checking
assert.strictEqual(isAcceptablePassword("short"), false);
assert.strictEqual(isAcceptablePassword("muchlonger"), false);
assert.strictEqual(isAcceptablePassword("ashort"), false);
assert.strictEqual(isAcceptablePassword("muchlonger5"), true);
assert.strictEqual(isAcceptablePassword("sh5"), false);
assert.strictEqual(isAcceptablePassword("1234567"), false);
console.log("Coding complete? Click 'Check Solution' to earn rewards!");
May 2, 2023
Comments: