
set_readmore(
    document.getElementById('olga_readmore'),
    document.getElementById('olga_readmore_btn'),
    'Leggi tutto', 'Meno'
)
set_readmore(
    document.getElementById('yana_readmore'),
    document.getElementById('yana_readmore_btn'),
    'Leggi tutto', 'Meno'
)
set_readmore(
    document.getElementById('shkapa_readmore'),
    document.getElementById('shkapa_readmore_btn'),
    'Leggi tutto', 'Meno'
)
set_readmore(
    document.getElementById('surikova_readmore'),
    document.getElementById('surikova_readmore_btn'),
    'Leggi tutto', 'Meno'
)
set_readmore(
    document.getElementById('ermolaeva_readmore'),
    document.getElementById('ermolaeva_readmore_btn'),
    'Leggi tutto', 'Meno'
)
set_readmore(
    document.getElementById('stepina_readmore'),
    document.getElementById('stepina_readmore_btn'),
    'Leggi tutto', 'Meno'
)
function set_readmore (text, btn, more, less) {
  more = more || 'Read more'
  less = less || 'Hide'
  btn.innerHTML = more
  btn.onclick = function () {
    if (text.style.display === 'none') {
      text.style.display = 'inline'
      btn.innerHTML = less
    } else {
      text.style.display = 'none'
      btn.innerHTML = more
    }
  }
}

function setReadmore (text, btn, more, less) {
  if (!text || !btn) { return } 
  more = more || 'Read more'
  less = less || 'Hide'
  btn.innerHTML = more
  btn.onclick = function () {
    if (text.style.display === 'none') {
      text.style.display = 'inline'
      btn.innerHTML = less
    } else {
      text.style.display = 'none'
      btn.innerHTML = more
    }
  }
}

[
  'olga',
  'yana',
  'ermolaeva',
  'stepina'
].forEach(function (name) {
  const text = document.getElementById(name + '_readmore')
  const btn = document.getElementById(name + '_readmore_btn')
  setReadmore(text, btn, 'Leggi tutto', 'Meno')
})



Fix bug when it crashes on non existent ids. Refactor
Fix bug when it crashes on non existent ids. Refactor
