Skip to content

Instantly share code, notes, and snippets.

@Rishit-dagli
Created March 31, 2020 13:31
Show Gist options
  • Save Rishit-dagli/974e95c287853b6f67c78f98831d6a39 to your computer and use it in GitHub Desktop.
Save Rishit-dagli/974e95c287853b6f67c78f98831d6a39 to your computer and use it in GitHub Desktop.
Addon script.js for loading data
/**
* 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