'comparing arrays in Javascript with index [duplicate]
Say you have, an array and you're comparing particular elements of that array (with an index) to another array. It returns false although the values of the elements are the same. Why is that?
const arr1 = [1, 3, 5, 7];
[arr1[0], arr1[1]] === [1,3] // false
Solution 1:[1]
Add the following to your script:
if (request.url === '/') {
response.end()
} else if (request.url === '/coucou') {
page+=markdown.toHTML('#Hello world!')
response.end(page)
console.log("end")
} else {
console.log("No response for "+request.url);
}
The log output should explain what's happening: there's a third case in which you never were ending the response.
A look in the network panel of your browser's devtools will also show you which request is still hanging without a complete response.
It's most likely the favicon that a browser requests by default. The page content will have loaded, but the status bar will still show "loading". As @jfriend suggests, use
response.status(404).end();in theelseblock
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
