I'm currently working on a Node JS/Puppeteer project which inputs characters on a registration form from a dictionary that changes with a variable. For this I made a big chunk of code:
if (c1 == 1){
"a" = dict["Chara1"]
} else {
if (c1 == 2) {
"b" = dict["Chara1"]
} else {
if (c1 == 3){
"c" = dict["Chara1"]
} else {
if (c1 == 4) {
"d" = dict["Chara1"]
} else {
if (c1 == 5){
"e" = dict["Chara1"]
} else {
if (c1 == 6) {
"f" = dict["Chara1"]
} else {
if (c1 == 7){
"g" = dict["Chara1"]
} else {
if (c1 == 8) {
"h" = dict["Chara1"]
} else {
if (c1 == 9){
"i" = dict["Chara1"]
} else {
if (c1 == 10) {
"j" = dict["Chara1"]
} else {
if (c1 == 11){
"k" = dict["Chara1"]
} else {
if (c1 == 12) {
"l" = dict["Chara1"]
} else {
if (c1 == 13){
"m" = dict["Chara1"]
} else {
if (c1 == 14) {
"n" = dict["Chara1"]
} else {
if (c1 == 15){
"o" = dict["Chara1"]
} else {
if (c1 == 16) {
"p" = dict["Chara1"]
} else {
if (c1 == 17){
"q" = dict["Chara1"]
} else {
if (c1 == 18) {
"r" = dict["Chara1"]
} else {
if (c1 == 19){
"s" = dict["Chara1"]
} else {
if (c1 == 20) {
"t" = dict["Chara1"]
} else {
if (c1 == 21){
"u" = dict["Chara1"]
} else {
if (c1 == 22) {
"v" = dict["Chara1"]
} else {
if (c1 == 23){
"w" = dict["Chara1"]
} else {
if (c1 == 24) {
"x" = dict["Chara1"]
} else {
if (c1 == 25){
"y" = dict["Chara1"]
} else {
if (c1 == 26) {
"z" = dict["Chara1"]
} else {
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
As I'm a beginner in Node JS I've tried to search tutorials or documentation, but I didn't find/understand anything and I know that it's probably gonna end with a Node JS crash or something that doesn't work as this chunk of code will be in 8 copy. I want to know how to make it smaller.
Ps: Sorry if my English is bad, I'm not Anglophone.