{"size": 1206, "ext": "js", "max_stars_repo_path": "src/lab45/exercise3/index.js", "max_stars_repo_name": "roybenenosh/frontend-training", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/lab45/exercise3/index.js", "max_issues_repo_name": "roybenenosh/frontend-training", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/lab45/exercise3/index.js", "max_forks_repo_name": "roybenenosh/frontend-training", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.6595744681, "max_line_length": 74, "alphanum_fraction": 0.64013267}
const strengths = {
  Week: { color: 'red' },
  Medium: { color: 'orange' },
  Strong: { color: 'green' }
};

const symbols = ['!', '#', '$', '@', '*'];

function onTextChange() {
  let password = document.querySelector('#password-input').value;
  let smallExists = false;
  let capitalExists = false;
  let numberExists = false;
  let symbolExists = false;

  if (password.length < 5) {
    updateLabel('Week');
    return;
  }

  const chars = Object.assign([], password);

  for (let index = 0; index < chars.length; index++) {
    if (chars[index] === chars[index].toUpperCase()) capitalExists = true;
    if (chars[index] === chars[index].toLowerCase()) smallExists = true;
    if (parseInt(chars[index]) !== NaN) numberExists = true;
    if (symbols.includes(chars[index])) symbolExists = true;
  }

  if (smallExists && capitalExists && numberExists && symbolExists) {
    updateLabel('Strong');
    return;
  }

  if (smallExists && capitalExists && numberExists) {
    updateLabel('Medium');
    return;
  }
}

function updateLabel(strength) {
  let color = strengths[strength].color;
  let label = document.querySelector('#strength');
  label.style.color = color;
  label.innerText = strength;
}
