I’m trying to create a little JavaScript tool where I can create the combinations out of three lists. Each combination consists of one consonant, one niqqudot, and one teamim. I thought it could be solved with simple nested loops, but the “document.write” line results in an infinite loop and it does not seem to increment. The first combination is repeated over and over, but it never goes to the next combination. I would greatly appreciate it if someone could take a look at the code and see why that might be. Thanks!
function combine()
{
// lists
var consonants = ["א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט", "י", "ך", "כ", "ל", "ם", "מ", "ן", "נ", "ס", "ע", "ף", "פ", "ץ", "צ", "ק", "ר", "שׁ", "שׂ", "ת"];
var niqqudot = ["", "ְ", "ֱ", "ֲ", "ֳ", "ִ", "ֵ", "ֶ", "ַ", "ָ", "ֹ", "ֻ", "ׇ", "ֿ", "ׄ", "ׅ", "ּ", "ֽ"];
var teamim = ["", "֑", "֒", "֓", "֔", "֕", "֖", "֗", "֘", "֙", "֚", "֛", "֜", "֝", "֞", "֟", "֠", "֡", "֢", "֣", "֤", "֥", "֦", "֧", "֨", "֩", "֪", "֫", "֬", "֭", "֮", "֯"];
// all combinations
var combinations = "";
// counter variables
var i = 0;
var j = 0;
var k = 0;
for (i = 0; i < consonants.length; i+1)
{
for (j = 0; j < niqqudot.length; j+1)
{
for (k = 0; k < teamim.length; k+1)
{
//combinations = combinations + consonants[i] + niqqudot[j] + teamim[k]+ "\r\n" ;
document.write(consonants[i] + niqqudot[j] + teamim[k] + "\r\n");
}
}
}
}
The expressions
don’t alter the values of the counting variables themselves. They simply evaluate, and have no side effects. You need to say i+=1, j+=1, k+=1. Otherwise, how would the interpreter know what variable to assign the value to?