Skip to content

Commit 9944e25

Browse files
Wayleom Vargas RubioWayleom Vargas Rubio
authored andcommitted
lesson06 working on stretch assignment
1 parent 8830b7b commit 9944e25

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
function isValidAlphaAbbreviation(word: string, abbr: string): boolean {
2-
if (word.length < 1 || word.length > 25 || abbr.length < 1 || abbr.length > 15) {
3-
return false;
4-
}
2+
let wordlength = word.length;
3+
let abbrlength = abbr.length;
54

6-
const hasNumbers = (str: string): boolean => /\d/.test(str);
7-
if (hasNumbers(word) || hasNumbers(abbr)) {
8-
return false;
9-
}
10-
11-
let wordIndex = 0;
12-
let abbrIndex = 0;
13-
14-
const letterToNumber = (char: string): number => {
15-
return char.charCodeAt(0) - 'a'.charCodeAt(0) + 1;
16-
};
5+
if (wordlength < abbrlength) return false;
6+
if (word.length < 1 || word.length > 25) return false;
7+
if (abbr.length < 1 || abbr.length > 15) return false;
8+
if (!/^[a-z]+$/.test(word)) return false;
9+
if (!/^[a-z]+$/.test(abbr)) return false;
1710

1811

19-
}
2012

13+
return true;
14+
}

0 commit comments

Comments
 (0)