| 154 | |
| 155 | // Function responsible to generate password and then returning it. |
| 156 | function generatePassword(length, lower, upper, number, symbol) { |
| 157 | let generatedPassword = ""; |
| 158 | const typesCount = lower + upper + number + symbol; |
| 159 | const typesArr = [{ lower }, { upper }, { number }, { symbol }].filter(item => Object.values(item)[0]); |
| 160 | if (typesCount === 0) { |
| 161 | return ""; |
| 162 | } |
| 163 | for (let i = 0; i < length; i++) { |
| 164 | typesArr.forEach(type => { |
| 165 | const funcName = Object.keys(type)[0]; |
| 166 | generatedPassword += randomFunc[funcName](); |
| 167 | }); |
| 168 | } |
| 169 | return generatedPassword.slice(0, length); |
| 170 | } |
| 171 | |
| 172 | // function that handles the checkboxes state, so at least one needs to be selected. The last checkbox will be disabled. |
| 173 | function disableOnlyCheckbox(){ |