Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <button>Show Next</button>
  <span class="quotes"></span>
</body>
</html>
 
const quotes = '1.lorem 2.ipsum 3.dolor 4.sit 5.amet'.split(' ').sort(_ => Math.random()-.5);
const span = document.querySelector('span');
const maxIndex = quotes.length;
let currentIndex = 0;
function showQuote(index) {
  span.textContent = quotes[index];
}
document
  .querySelector('button')
  .addEventListener('click', () => {
    currentIndex = ++currentIndex % maxIndex;
    showQuote(currentIndex);
  })
;
showQuote(currentIndex);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers