codice:
function contetore(){
var contatore1= 0;
var contatore2= 0;
var contatore3= 0;
var contatore4= 0;
var contatore5= 0;
var contatore6= 0;
var contatore7= 0;
var contatore8= 0;
var contatore9= 0;
var contatore10= 0;
var contatoregenerale= 0;
if (contatoregenerale=0){
var RadiceInserita1 =JSON.stringfy(radice);
localStorage.setItem ("radice", RadiceInserita1);
contatore1 = contatore1+1;
contatoregenerale=contatoregenerale+1;
}
if (contatoregenerale>=1){
if ("radice"== RadiceInserita1){
contatore1=contatore1+1;
contatoregenerale=contatoregenerale;
} else {
if (contatoregenerale==1){
var RadiceInserita2 =JSON.stringfy(radice);
localStorage.setItem ("radice", RadiceInserita2);
contatore2 = contatore2+1;
contatoregenerale=contatoregenerale+1;
}
if (contatoregenerale>=2){
if ("radice"== RadiceInserita2){
contatore2=contatore2+1;
contatoregenerale=contatoregenerale;
} else {
if (contatoregenerale==2){
var RadiceInserita3 = JSON.stringfy(radice);
localStorage.setItem ("radice", RadiceInserita3);
contatore3 = contatore3+1;
contatoregenerale=contatoregenerale+1;
}
if (contatoregenerale >=3) {
if ("radice"== RadiceInserita3){
contatore3=contatore3+1;
contatoregenerale=contatoregenerale;
} else {
if (contatoregenerale==3){
var RadiceInserita4 = JSON.stringfy(radice);
localStorage.setItem ("radice", RadiceInserita4);
contatore4 = contatore4+1;
contatoregenerale=contatoregenerale+1;
}
if (contatoregenerale>=4) {
if ("radice"== RadiceInserita4){
contatore4=contatore4+1;
contatoregenerale=contatoregenerale;
}else {
if (contatoregenerale==4){
var RadiceInserita5 =JSON.stringfy(radice);
localStorage.setItem ("radice", RadiceInserita5);
contatore5 = contatore5+1;
contatoregenerale=contatoregenerale+1;
}
if (contatoregenerale >=5) {
if ("radice"== RadiceInserita5){
contatore5=contatore5+1;
contatoregenerale=contatoregenerale;
} else {
if (contatoregenerale==5){
var RadiceInserita6 =JSON.stringfy(radice);
localStorage.setItem ("radice", RadiceInserita6);
contatore6 = contatore6+1;
contatoregenerale=contatoregenerale+1;
[...]
io ho provato a fare un contatore in questo modo il contatore, ma sicuramente contiene errori, il problema è che non capisco dove siano ((....il problema nell'utilizzare questo contatore è che quando lo inserisco mi blocca il programma...(questo è la prima parte del contatore ma si ripete fino al contatore 10)