Janechen88
New Coder
Hello dear community,
I have a problem and I don't know exactly how to solve it.
I have a code that calculates the checksum of a number and then outputs it.
I would now have to adapt the code so that the number "10" can also come out as a solution.
That means the checksum of 91 should be 10 and not 1 (so the number must be >10 so that it calculates the checksum)
how can I add an if condition or something else to my code that I achieve this result.
I would be really grateful for suggestions and solutions 🙂
I have a problem and I don't know exactly how to solve it.
I have a code that calculates the checksum of a number and then outputs it.
I would now have to adapt the code so that the number "10" can also come out as a solution.
That means the checksum of 91 should be 10 and not 1 (so the number must be >10 so that it calculates the checksum)
how can I add an if condition or something else to my code that I achieve this result.
I would be really grateful for suggestions and solutions 🙂
JavaScript:
jQuery( function( $ ) {
$("input[name='wpcf-geburtdatumzahl1']").change(quersumme);
function quersumme() {
var tmp = $("input[name='wpcf-geburtdatumzahl1']").val().split('');
var quer = 0;
for (var i=0; i < tmp.length; i++) {
quer += Number(tmp[i]);
}
var round2 = quer.toString().split('');
var round2_res = 0;
for (var i=0; i < round2.length; i++) {
round2_res += Number(round2[i]);
}
$("input[name='wpcf-loesungszahl01']").val(round2_res);
}
} );
Last edited by a moderator: