Skip to content

Commit ecf9e10

Browse files
committed
replaced deprecated code
1 parent cd0df58 commit ecf9e10

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

script.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,22 @@ let alphaNums = ['A', 'B', 'C', 'D', 'E', 'F', 'G',
2222
'q', 'r', 's', 't', 'u', 'v', 'w',
2323
'x', 'y', 'z', '0', '1', '2', '3',
2424
'4', '5', '6', '7', '8', '9'];
25-
let emptyArr = [];
25+
2626

2727
// This loop generates a random string of 7 characters using alphaNums
2828
// Further this string is displayed as a CAPTCHA
29+
let emptyArr = [];
2930
for (let i = 1; i <= 7; i++) {
3031
emptyArr.push(alphaNums[Math.floor(Math.random() * alphaNums.length)]);
3132
}
3233
var c = emptyArr.join('');
33-
ctx.fillText(emptyArr.join(''),captchaText.width/4, captchaText.height/2);
34-
34+
ctx.fillText(emptyArr.join(''), captchaText.width/4, captchaText.height/2);
3535

3636
// This event listener is stimulated whenever the user press the "Enter" button
37-
// "Correct!" or "Incorrect, please try again" message is
37+
// "Correct!" or "Incorrect, please try again!" message is
3838
// displayed after validating the input text with CAPTCHA
3939
userText.addEventListener('keyup', function(e) {
40-
// Key Code Value of "Enter" Button is 13
41-
if (e.keyCode === 13) {
40+
if (e.key === 'Enter') {
4241
if (userText.value === c) {
4342
output.classList.add("correctCaptcha");
4443
output.innerHTML = "Correct!";

0 commit comments

Comments
 (0)