why the code below is returning false ??
let str = “i love sun”;
let regex = /un./;
let result = regex.test(str);
but when i change let str = “i love sun and fun”; it return true.
according to tutorial. any word like - sun, bun, fun should return true because we are using wild card un. ? what am i missing here??
thanks for help
I’m confused by your question. ‘i love sun and fun’ contains ‘un’, so why don’t you expect it to match your regex?
thats what i am having trouble as well like from fcc page :
let exampleStr = “Let’s have bun with regular expressions!”;
let unRegex = /un./; // Change this line
let result = unRegex.test(exampleStr);
it return true but when i change the sentence to “i love sun”. it console logs false… but its should be still true because of un. using wild card
un means that the “un” in the string must be followed by some character. In “i love sun” there is no character after the “un” so it doesn’t match the pattern.
ah!! i seee , just tested what u said and it worked… thanks alot !
I’m glad I could help. Happy coding!