I've been writing a program to improve my Javascript skills.It's a very simple app for typing practicing.var excercise = The Battle of Westerplatte was the first battle in the Invasion of Poland and marked the start of the Second World War in Europe. Beginning on September 1, 1939, German naval forces and soldiers assaulted the Polish Military Transit Depot (Wojskowa Skladnica Tranzytowa, WST) on the peninsula of Westerplatte, in the harbour of the Free City of Danzig. The depot was manned by fewer than 200 soldiers, but held out for seven days in the face of a heavy attack that included dive bomber attacks.;var excerciseTextP = document.getElementById('excercisetext');var textarea = document.getElementById('textarea');var time = 0;var isTimeRunning = false;var intervalId = null;function appendExcerciseText() {  var text = document.createTextNode(excercise);  excerciseTextP.appendChild(text);}/** * Create html textarea with same size as paragraph with excercise text */function setWidthAndHeightToTexarea() {  var width = excerciseTextP.clientWidth;  var height = excerciseTextP.clientHeight;  textarea.style.width = width + 'px';  textarea.style.height = height + 10 + 'px';}function setFocus() {  textarea.focus();}function checkWriting(event) {  if (!isTimeRunning) {    isTimeRunning = true;    stopWatch();  }  if (event.target.value.length == excercise.length - 1) {    clearInterval(intervalId); // stop stopwatch    //console.log(time);    wpmSpeed();  }  var lastChar = event.target.value.length;  var typing = String.fromCharCode(event.keyCode);  if (excercise[lastChar] !== typing) {    event.preventDefault(); // cancel event    showCorrectCharacter(excercise[lastChar]);    replaceExcercise();    appendErrorCount();  } else {    showCorrectCharacter('');  }}/** * Replace onscreen excercise * @return {[type]} [description] */function replaceExcercise() {  var lastChar = event.target.value.length;  var p = document.getElementById('excercisetext');  var textWithMistake = p.textContent;  var beforeMistake = textWithMistake.substr(0, lastChar);  var afterMistake = textWithMistake.substr(lastChar + 1, excercise.length - 1);  excerciseTextP.textContent = beforeMistake + '_' + afterMistake;}/** * Split typed string by '_' and return its length * @return [number] how many '_' chatacters (which idicates wrong character) is in typed text */function errorCount() {  var matches = excerciseTextP.textContent.split('_');  var errors = matches.length - 1;  return errors;}function appendErrorCount() {  removeErrorCount();  var errorSpan = document.getElementById('errors');  var text = document.createTextNode(errorCount());  errorSpan.appendChild(text);}function removeErrorCount() {  var errorSpan = document.getElementById('errors');  if (errorSpan.firstChild) {    errorSpan.removeChild(errorSpan.firstChild);  }}function stopWatch() {  var now = setInterval(addsecond, 1000);  intervalId = now;}function addsecond() {  showTime();  return time++;}function showTime() {  var timeSpan = document.getElementById('time');  timeSpan.textContent = secondToMinutes(time);}/** * Show right character after wrong was pressed. * @param  {[string]} */function showCorrectCharacter(character) {  var correctSpan = document.getElementById('correctcharacter');  if (character == ' ') {    character = 'space';  } else {    correctSpan.textContent = character;  }}function secondToMinutes(time) {  var minutes = Math.floor(time / 60);  var seconds = Math.floor(time % 60);  if (seconds < 10) {    seconds = '0' + seconds;  }  return minutes + ' : ' + seconds;}function wordsCount() {  var words = Math.floor((excercise.length) / 5); //one word id 5 characters  return words;}/** * Counts Gross WPM rate */function wpmSpeed() {  var totaltime = time;  var words = wordsCount();  console.log(totaltime + ' = ' + (totaltime / 60) + 'min' + 'words: ' + words);  var wpm = Math.floor(words / (totaltime / 60));  console.log(wpm);}appendExcerciseText();setWidthAndHeightToTexarea();window.addEventListener('load', setFocus, false);textarea.addEventListener('keypress', checkWriting, event, false);<div class=container id=container>  <div class=row>    <div class=col-md-12>      <h1>Typexer</h1>    </div>  </div>  <div class=row>    <div class=col-md-6>      <p>Excercise text</p>      <p id=excercisetext></p>    </div>    <div class=col-md-6> <span id=correctcharacter style=font-size: 90px;></span>    </div>  </div>  <div class=row>    <div class=col-md-6 id=excercisediv>      <p>Write here:</p>      <div id=excercisebox>        <textarea id=textarea></textarea>      </div>    </div>  </div>  <div class=row>    <div class=col-md-2>Errors <span id=errors></span>    </div>    <div class=col-md-2></div>    <div class=col-md-2>Time:&nbsp;<span id=time></span>    </div>  </div>I'm not sure if using global variables at the top of code is a good practice.
Typing exercise app
javascript;beginner