I have many same blocks of Javascript code with only difference is the id.
if(numEduIndex == 1){
var editorEduDes = CKEDITOR.instances.edu_description_1;
editorEduDes.on('paste', function (evt) {copyPasteCkeditor(evt)});
}
if(numEduIndex == 2){
var editorEduDes = CKEDITOR.instances.edu_description_2;
editorEduDes.on('paste', function (evt) {copyPasteCkeditor(evt)});
}
if(numEduIndex == 3){
var editorEduDes = CKEDITOR.instances.edu_description_3;
editorEduDes.on('paste', function (evt) {copyPasteCkeditor(evt)});
}
I want to use for loop to clean code, like this:
for (let i = 1; i <= 31; i++) {
if(numEduIndex == i){
var editorEduDes = CKEDITOR.instances.edu_description_ + i;
editorEduDes.on('paste', function (evt) {copyPasteCkeditor(evt)});
}
}
The problem I have is I can not concat i
to the id edu_description
.
Is there anyway I can do this with for loop?
Thank you all!