quote generator code example
Example: how to write random quote machien
const getQuote = data => {
// 1) here we are creating the callback function that we will pass to the JSONP request
const callbackName = 'displayQuote'
window[callbackName] = function(data) {
delete window[callbackName]
document.body.removeChild(script)
callback(data)
}
// 2) we are injecting the script tag into our HTML
const script = document.createElement('script')
script.src =
url + (url.indexOf('?') >= 0 ? '&' : '?') + 'callback=' + callbackName
document.body.appendChild(script)
}