I am trying to format my array to a formatted string, how can I do that? The instructions I was given are
Task 6 - find all odd numbers in a list.
Allow any number of Number arguments to be passed to the function.
If a value is passed to the function that is not a Number, ignore it
and continue processing the rest. If the list is empty (nothing passed
to the function, or all need to be ignored, return null
).
Return a formatted string with all odd numbers in a list, for example:
"1, 3, 5"
<script>
var odd = [];
const oddNumbers = (...numbers) => {
var oddNum
var formatString;
var i;
if (numbers.length > 0) {
for (i = 0; i < numbers.length; i++) {
if (isNaN(numbers[i]) === false && (numbers[i] % 2 !== 0)) {
odd.push(numbers[i]);
console.log(odd);
}
}
} else {
return null;
}
return odd;
};
oddNumbers(1, 2, 34, 54, 55, 34, 32, 11, 19, 17, 54, 66, 13);
alert(odd);
</script>