Skip to content

Instantly share code, notes, and snippets.

@yayMark
Last active September 17, 2019 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yayMark/8b70d1fd26bde620f5871483fa7c5f35 to your computer and use it in GitHub Desktop.
Save yayMark/8b70d1fd26bde620f5871483fa7c5f35 to your computer and use it in GitHub Desktop.
JavaScript: carsales.com.au helper - get the year of the car and odometer reading from the DOM
// year of car
document.querySelector('.details-wrapper h1').innerText.split(' ')[0]
// odometer
Number(document.querySelector('.key-details-item-title').innerText.split(' ')[0].replace(/,/g, ''))/20000
// 20000 km average a year
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment