I am currently working on a program that automatically generates ASCII text based on input numbers. Essentially, when a number is provided as input to the function, it will be displayed as magnified ASCII text. For example, an input of 0123456789 would generate the following:
-**----*--***--***---*---****--**--****--**---**--
*--*--**-----*----*-*--*-*----*-------*-*--*-*--*-
*--*---*---**---**--****-***--***----*---**---***-
*--*---*--*-------*----*----*-*--*--*---*--*----*-
-**---***-****-***-----*-***---**---*----**---**--
--------------------------------------------------
I have organized each number into an array and my code loops through this array for each number entered, eventually building the final combined image. The generation process appears to be functioning correctly, but I am encountering an issue where the end variable is not being properly accessed at the conclusion. The main loop only processes the initial number from the input before stopping. Any assistance with resolving this problem would be greatly appreciated! http://jsfiddle.net/dmcuj2z5/
function printNums(line){
var nums = [['12','03','03','03','12'],['2','12','2','2','123'],['012','3','12','0','0123'],['012','3','12','3','012'],['1','03','0123','3','3'],['0123','0','012','3','012'],['12','0','012','03','12'],['0123','3','2','1','1'],['12','03','12','03','12'],['12','03','123','3','12']];
var answer = ['','','','','',''];
var allowed = '0123456789';
for(var i=0;i<line.length;i++){
var num = line[i];
if(allowed.indexOf(num) !== -1){
for(var l=0;l<6;l++){
var print = '';
for(var c=0;c<5;c++){
if(nums[num][l].indexOf(c) !== -1){
print += '*';
}else{
print += '-';
}
}
answer[l] += print;
}
}
}
alert(answer);
}
printNums('123');