-
Notifications
You must be signed in to change notification settings - Fork 0
Week 1
Kevin Boere edited this page Oct 17, 2023
·
22 revisions
The following array contains multiple data types. Normalize them by converting them all to numbers using a function and log the result in the console
|
Given Example |
My Solution |
|---|---|
const data = [
1,
2,
"3",
"4",
5
]
function convertArrayStringsToNumbers() {
/* Your code here should convert the data array to
an array containing only numbers and no strings
and log the code to the console. */
}
convertArrayStringsToNumbers(); |
const data = [
1,
2,
"3",
"4",
5
]
function convertArrayStringsToNumbers() {
/* convert the array into only numbers */
let newArray = data.map(Number);
/* log the array */
console.log(newArray)
}
convertArrayStringsToNumbers(); |
Wiki By Kevin Boere | Minor Information Design - Tech Track | 2023-2024