My code
const upperCase = 'QWERTYUIOPASDFGHJKLZXCVBNM'.split('');
const lowerCase = 'qwertyuiopasdfghjklzxcvbnm'.split('');
const numbers = '1234567890'.split('');
const symbols = '@#£&*()\'"%-+=/;:,.€$¥_^[]{}§|~…\\<>!?'.split('');
var exclude = [];
var fullList = [];
var allowUpperCase = true;
var allowLowerCase = true;
var allowSymbols = true;
var allowNumbers = true;
function genList() {
if (allowUpperCase) {
fullList.concat(upperCase);
}
if (allowLowerCase) {
fullList.concat(lowerCase);
}
if (allowSymbols) {
fullList.concat(symbols);
}
if (allowNumbers){
fullList.concat(numbers)
}
}
genList();
console.log(fullList);
What it is suppose to do: Basically to check if the user want those characters and then add them to the “fullList” array
But then when I do genList and console.log(fullList) it appears to be empty []
Why?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
Array concat method does not modify the current array but returns a new one. Modify the method like this & it will work.