Break vs continue vs return
Created by Codedamn about a year ago
No description provided
20 Comments
could you make this tutorial a bit more explained
i dont really get this
why i+=2 can you please explain...
in simple words, if you use continue with condition , the generated result get skipped in output.
The single equal to (=) sets the value The double equal to (==) checks the value And the triple equal to (===) checks the value as well as the data type.
I couldn't get anything from this video. need to update this video with a better explanation.
is too fast.
Dear please start explaining to beginners , your style of explanation not even for Juniors but for Middle programists
This is the best JavaScript for beginner course that I have taken. I am learning a lot from this stuff bruv. Thanks a lot Mahul!
Poor Explanation!
I didn't understand this :(
Very well explained
Confusing Video
I believe the idea came randomly to him while recording the video, here's the summary of what he exactly wanted to convey: (just copy paste it on to your editor to see the difference & usecase between break and continue):
//--------------------------------------------------// // break(stops) and continue(skip)
function skipNumber(number){ let remainingNumbers =[]
for (let i=0; i<=10 ; i++){
if (i=== number){
continue
}
remainingNumbers.push(i)
}
return remainingNumbers
}
console.log(skipNumber(6))
//--------------------------------------------------// /* break: breaks the iteration and continue: skipping in iteration*/
function breakNumber(number){ let remainingNumbers =[]
for (let i=0; i<=10 ; i++){
if (i=== number){
break
}
remainingNumbers.push(i)
}
return remainingNumbers
}
console.log(breakNumber(6))
What break does is it exits the loop, nothing below of it will execute , whereas continue just says skip this move on to next, and if you use return in place of break, you not only exit the loop but also the function and function is made to return something, I hope it clears, Keep going Champs!!