SyntaxError: Invalid destructuring assignment target

Hello, i need to create a web site with a decreasing timer and i got a syntaxError but i don’t know what to change:


var secondesrestantes;
var interval;
var boutonstart=document.getElementById("start");

boutonstart.onclick=function({
	startminuteur();  //ERROR !
	};
function reinitialiser(){
	document.getElementById("tempsIndiqué").style.display="block";
}

function tick(){
	var tempsrestant=document.getElementById("temps");
	varmin=Math.floor(secondesrestantes/60);
	var sec=secondesrestantes-(min*60);
	if (sec<10){
		sec="0"+sec;
	}
	
	var message=min.toString+":"+sec;
	tempsrestant.innerHTML=message;
	if(secondesrestantes===0){
		alert("Done!");
		clearInterval(interval);
		reinitialiser();
	}
	secondesrestantes--;
}

function startminuteur(){
	reinitialiser()
	var minutes=Math.floor(document.getElementById("minutes").value);
	if (isNaN(minutes)||minutes==""){
		alert("Veuillez entrer un nombre");
		return;
	}
	secondesrestantes==minutes*60;
	interval=setInterval(tick,1000);
	document.getElementById("tempsIndiqué").style.display="none";
}

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

I could see no destructuring in your code.
There is a condition in this line, maybe you meant to use the assigment operator isntead:

secondesrestantes==minutes*60;
1 Like

That’s good thank you !