Toggle class

Read this and write example

https://ultimatecourses.com/blog/stop-toggling-classes-with-js-use-behaviour-driven-dom-manipulation-with-data-states

 http://api.jquery.com/toggleclass/


https://www.w3schools.com/howto/howto_js_toggle_class.asp

Switch case

Simple example

function tieinai(aaa) {

  switch (aaa) {
    case "1234":  return "kafe";
    case "1235":  return "gala";
    case "1236":  return "nero";
    case "1237":  return "milko";
    case "1238":  return "tyropita";
    case "1239":  return "tost";
    default:          return "OK";
  }
}

Best practice

function getDrink (type) {
"use strict";
  return   {
    'code1': 'milk',
    'code2': 'water',
    'code3': 'coffee'
  }[type] || "nothing";
}

alert(getDrink("code1"))

Replacing switch statements with Object literals