what does the expression in brackets if(!task) mean? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

what does the expression in brackets if(!task) mean?

const task = input.value; if(!task) { alert('Please, fill out the task'); return; }

7th Apr 2022, 12:07 PM
🕸carpe diem🕸
🕸carpe diem🕸 - avatar
1 Antwort
+ 1
Here input.value is nothing but u r trying to give a input Now coming to if statement !task=not task means here the value which you are giving is stored in that task variable i.e task contains input value if the user does not enter any value then that task does not contain any value now this we write it as !task which means if the user does not enter a value then we will represent as !task and when the condition is true then alert function is called.
7th Apr 2022, 12:20 PM
UNKNOWN