Regex in exercise 4 doesn't work


#1

https://www.codecademy.com/courses/javascript-intermediate-en-NJ7Lr/0/4

I didn't know where to post this as the category for that particular course doesn't seem to exist for some reason.

I'm using the following regex /^a.*$/


console.log("Approximative Alphabet");
var ApproximativeAlphabet  = /^a.*z$/;
console.log(ApproximativeAlphabet.test("az")?"good":"bad");
console.log(ApproximativeAlphabet.test("a#z")?"bad":"good");
console.log(ApproximativeAlphabet.test("abcdefghijklmnopqrstuvwxyz")?"good":"bad");
console.log(ApproximativeAlphabet.test("aaazzz")?"bad":"good");
console.log(ApproximativeAlphabet.test("abcaz")?"bad":"good");
console.log(ApproximativeAlphabet.test("abczz")?"bad":"good");
console.log(ApproximativeAlphabet.test("abgyz")?"good":"bad");
console.log(ApproximativeAlphabet.test("aghzn")?"bad":"good");
console.log(ApproximativeAlphabet.test("arrz")?"good":"bad");
console.log(ApproximativeAlphabet.test("afkmvz")?"good":"bad");


This is the output:

Approximative Alphabet
good
bad
good
bad
bad
bad
good
good
good
good

All cases are supposed to return "Good", however, four of them aren't. I don't know what to include in my regex for it to work.


#2

Find now a regular expression for the regexp ApproximativeAlphabet on line 12 which validate a string that starts with "a" and ends with "z" and contains anything between b and y

This would rule out /.*/ since that will pass *anything* appearing betweenaandz`. How might you write the regex that satisfies the above condition?

Pay careful note to the way the expressions are written. Some are ? "bad":"good" and others are ? "good":"bad"

Compare the test strings in these and see if you can explain why some should fail.