Skip to content

Instantly share code, notes, and snippets.

@ohiosveryown
Created November 5, 2018 16:20
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 ohiosveryown/1aa63da70660d325b15a695c545c40b4 to your computer and use it in GitHub Desktop.
Save ohiosveryown/1aa63da70660d325b15a695c545c40b4 to your computer and use it in GitHub Desktop.
Single Random Entry from Array
const h1 = document.querySelector('h1')
const pages = [
'<a target="_blank" href="http://google.com">Google</a>',
'<a target="_blank" href="http://apple.com">Apple</a>',
'<a target="_blank" href="http://nike.com">Nike</a>',
'<a target="_blank" href="http://adidas.com">Adidas</a>',
]
const page = pages[~~(Math.random() * pages.length)]
// const page = pages[pages.length * Math.random() | 0]
h1.innerHTML = page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment