← Back to challenges

RegEx: Boundary Assertions I

JavaScriptHardformattingregexvalidation

Instructions

Assume a program only reads .js or .jsx files. Write a function that accepts a file path and returns true if it can read the file and false if it can't.

Examples

isJS("/users/user.jsx") ➞ true

isJS("/users/user.js") ➞ true

isJS("/users/user.ts") ➞ false

Notes

Use a RegEx boundary assertion in your function.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: How Many Decimal Places?