I have a url returned in url
as a string.
I want to check if the url sent start with a specific path.
However, the console returns that url.startWith is not a function
.
I am using Node.js.
function fun(url){
console.log(url) //returns https://www.example.com /page_1/12
const checkString = "https://www.example.com /page_1/"
console.log(checkString) //returns https://www.example.com/page_1/
if(url.startWith(checkString)){
console.log("true")
}else{
console.log("false")
}
}
Can you see what I am doing wrong?
I found a few posts with a similar topic, however the errors detailed in other posts seem to be related to the fact the variable was a value and not a string.