why is my code not working?
const word = "abcd123";
const filteredNum = word.split("").filter((e) => Number(e) !== NaN);
console.log(filteredNum);
CodePudding user response:
Try this:
const word = "abcd123";
const result = word.match(/\d /)[0];
console.log(result);
CodePudding user response:
using isNan() function
let word = "abcd123";
let filteredNum = word.split("").filter((e) => !isNaN(e));
console.log(filteredNum);
console.log(filteredNum.join(""))