My task involves working with a string containing only numbers.
For example:
let inputString = "1234";
The Challenge
I need to create a function that will return the string excluding the first even number, if one exists.
Example Output:
"134"
Sample Code:
let inputString = "1234";
function palindromeRearranging(inputString) {
/// code
}
console.log(palindromeRearranging(inputString));
// The output should be "134"
Attempted Solution
let inputString = "1234"
function palindromeRearranging(inputString) {
let arr = inputString.split("");
arr = arr.filter((w)=>{return w % 2 !== 0 })
return arr.join("")
}
console.log(palindromeRearranging(inputString))
However, this implementation is currently returning a string of all odd numbers.
Please help me understand what I am missing and how I can achieve my desired outcome. Your support is greatly appreciated!