Created
March 31, 2020 13:31
-
-
Save Rishit-dagli/974e95c287853b6f67c78f98831d6a39 to your computer and use it in GitHub Desktop.
Addon script.js for loading data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the car data reduced to just the variables we are interested | |
* and cleaned of missing data. | |
*/ | |
async function getData() { | |
const carsDataReq = await fetch('https://storage.googleapis.com/tfjs-tutorials/carsData.json'); | |
const carsData = await carsDataReq.json(); | |
const cleaned = carsData.map(car => ({ | |
mpg: car.Miles_per_Gallon, | |
horsepower: car.Horsepower, | |
})) | |
.filter(car => (car.mpg != null && car.horsepower != null)); | |
return cleaned; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment