I'm trying call a function, from a module, to build a HTML string. When the function is written in the below way, with a LF(Line Feed) between the return statement and the string declaration, the return is "undefined"...
exports.buildHtmlContent = function (content) {
return
"<!DOCTYPE html> \
\n<html lang='en-US'> \
\n <head> \
\n </head> \
\n <body> \
\n <h1>" + content + "</h1> \
\n </body> \
\n</html>";
};
However, when the function is written in this other below way, without the LF after return statement, it works properly!
exports.buildHtmlContent = function (content) {
return "<!DOCTYPE html> \
\n<html lang='en-US'> \
\n <head> \
\n </head> \
\n <body> \
\n <h1>" + content + "</h1> \
\n </body> \
\n</html>";
};
This is a bug in NodeJs? The NodeJs interpretation from the function 1 looks like it thinks the return is empty, even with the miss of ";", and didn't correlate the below string declaration with the return statement. Apparently NodeJs didn't check the miss of ";" before decide that is the interpretation end of the "return" statement.