function checkPalindrome(word) { for (let i = 0, j = word.length - 1; i < j; i++, j--) { if (word[i] !== word[j]) return false; } return true; } function checkPali(data, totalPoints=1, paliPoints=0, lenPoints=0) { // print("\
" + JSON.stringify(data, null, 2) + "\"); // debuggausta varten let len = 0; let jsparams = data.answer_call_data.markup.jsparams; if (jsparams) len = data.answer_call_data.markup.jsparams.minChars; let word = data.save_object.c.text; let p = [0,0]; data.web.console = ""; if (word.length < len) data.web.console += " Liian lyhyt!"; else p[0] = 1; if (!checkPalindrome(word)) data.web.console += " Ei ole palindromi!"; else p[1] = 1; if (p[0]+p[1] == 2) data.points = totalPoints; else data.points = p[0]*lenPoints + p[1]*paliPoints; data.web.console += " Pisteitä: " + data.points; return data; }