// utils/string.js
function removeNewLines(input) {
return input.replace(/(\r\n|\n|\r)/g, "").replace(/\s+/g, " ") .trim();
}
// module.exports = { removeNewLines };
// index.js
//const { removeNewLines } = require('./utils/string');
let str = 'c#\n javascript\n c++ \n c \n typescript \r node.js\n';
str = removeNewLines(str); // result without extra spaces
console.log(str);
/*
run:
c# javascript c++ c typescript node.js
*/