just two line of code is needed if you are going to use inbuilt method.
const reg = new RegExp(pattern);
return reg.test(inputLine);
you can still reduce alot of code.
const pattern = process.argv[3];
const inputLine = require(“fs”).readFileSync(0, “utf-8”).trim();
if (process.argv[2] !== “-E”) {
console.log(“Expected first argument to be ‘-E’”);
process.exit(1);
}
const reg = new RegExp(pattern);
process.exit(!reg.test(inputLine));
so dont use inbuilt method…