I'm confused as it is what or how i am suppose to do this

Tell us what’s happening:

Can’t figure out what i do wrong here
Your code so far


let sampleWord = "astronaut";
let pwRegex = /(?=a, b, c{1,2})/; // Change this line
let result = pwRegex.test(sampleWord);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15.

Challenge: Positive and Negative Lookahead

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead

Hello Kora.

Adding this to the last line of the script will help you see what is being matched by a regex:

console.log(sampleWord.match(pwRegex))

I recommend you begin from scratch, by resetting all your code for this challenge. Then, go through the lesson, and the tests one-by-one:

  1. Your regex should use two positive lookaheads
  2. Your regex should not match astronaut

Hope this helps

1 Like

Thanks for the reply
And be so kind not to reply to this one :3
But, i think i need to do some revieuws onto the previeuws lessons
looking as bellow is the best i can come up with…
it deffinitly needs some work

let sampleWord = "astronaut";

let pwRegex = /(?=\w{0,9})/; // Change this line

let pwRegex = /(?=\D*\d)/; // Change this line

let result = pwRegex.test(sampleWord);

console.log(sampleWord.match(pwRegex))

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

that will not work because you are redeclaring a variable declared with let, you can’t have both let pwRegex lines.
You also are not using 2 lookaheads. I suggest one for length, the other for pattern.