Story cover for Control Flow in JavaScript by mahesh1439
Control Flow in JavaScript
  • WpView
    Reads 1
  • WpVote
    Votes 0
  • WpPart
    Parts 1
  • WpHistory
    Time <5 mins
  • WpView
    Reads 1
  • WpVote
    Votes 0
  • WpPart
    Parts 1
  • WpHistory
    Time <5 mins
Ongoing, First published May 03, 2024
Control flow in JavaScript is a fundamental concept that dictates the order in which statements are executed within a script. It enables developers to control the flow of program execution based on conditions and loops. Understanding control flow is essential for writing efficient and logic-driven JavaScript code.

Conditional Statements

Conditional statements allow developers to execute code based on specific conditions. JavaScript provides several types of conditional statements:

if statement: This statement evaluates a condition and executes a block of code if the condition is true. For example:

if (condition) {
    // Code block to execute if condition is true
}

if...else statement: It executes one block of code if a condition is true and another block if the condition is false. Example:

if (condition) {
    // Code block to execute if condition is true
} else {
    // Code block to execute if condition is false
}

else if statement: This statement allows for multiple conditions to be checked sequentially. Example:

if (condition1) {
    // Code block to execute if condition1 is true
} else if (condition2) {
    // Code block to execute if condition2 is true
} else {
    // Code block to execute if neither condition1 nor condition2 is true
}
switch statement: It evaluates an expression and executes code based on a matching case label. Example:

switch (expression) {
    case value1:
        // Code block to execute if expression equals value1
        break;
    case value2:
        // Code block to execute if expression equals value2
        break;
    default:
        // Code block to execute if expression doesn't match any case
}

Loops

Loops are used to execute a block of code repeatedly until a specified condition is met. JavaScript supports different types of loops:

for loop: Executes a block of code a specified number of times. Example:

for (initialization; condition; iteration) {
    // Code block to execute
All Rights Reserved
Sign up to add Control Flow in JavaScript to your library and receive updates
or
Content Guidelines
You may also like
Mystery: Unspoken truth by mishi144
28 parts Complete
Ayeza was a modern girl,a lawyer by profession,all bubbly,full of life without worries.Getting entangled into a mystery of puzzles wasn't on her list.Being at 25 she found herself getting married to a mysterious man whom she never met on her parents wish. while the new life awaits for her she found herself a case of a mysterious murder of a young girl who was found dead in her apartment without a single lead.will she solve the case or will she'll throw herself into an even bigger mess? Do read the story to found out what mysteries awaits for ayeza! .................................... "I'm sorry" he said and I was furious at him now. "You're sorry? You ain't sorry. Nor you ever will be because you don't even know what that even mean." I spat at him controlling myself not to lash at him before I could get my answers from him. "Why did you do that to me? Why you played me?" I asked my voice breaking in middle. "I had my reasons." He replied shortly. "Don't you dare give me that crap. You are going to tell me everything right now or I'm going back to Pakistan and asking for divorce from you" I spat back at him. "Please calm down Ayeza. I'll tell you my every reason. But you need rest right now. We'll talk later" he said trying to touch my hands. "Don't touch me. Don't you dare come close to me even. And start talking if you don't want me to do anything reckless right now" I replied in raging tone. "Fine" he sighed hurt clear on his face ..................................... this is my first story so mistakes are posible please bear with me. Hope you enjoy the story Start: 29 November 2020 Ending: 8 February 2021
THE GANGSTER'S CRUSH- FAMILY OVER FREEDOM (SAMPLE) by qudseesheikh
11 parts Complete Mature
"Cupcake, if you don't agree to marry me, no one can help you from getting killed. You, your parents, and your friend they'll be dead the moment I step out, not because I want to kill you or them but because everyone who goes against my word must die, that's the rule. Marrying me will just keep you safe. Don't worry I am not a monster and yes, after today no one would dare think about marrying you" "What??" Rida thought the quota of her misery would be over, now that Drake was gone but the miseries were not done dealing with her. Zeus smirks looking at her, was this his plan all along? Rida followed him as he walked out of the venue. "Say your goodbyes we are leaving" Zeus states staring back at Rida who had no idea what just happened. "But- I- " "We don't have time" Zeus reminds her. "But-" "your parents will die Rida!" Rida agreed to marry the monster because of her parents, to keep them safe, and even now she has no choice but to leave with a stranger to assure their safety. "Can't you help-" Zeus stares at her, why would he help someone who means nothing to him, maybe he could have but why would he want to do that without a reason? "..." Which is a better option? Marrying a rapist or his boss? Rida was left with worse choices, but her parents' lives depended on her decision. Why? Who? When? Didn't matter when lives were at stake. Rida chooses to go with Zeus when promised to keep her parents alive and safe. She traded her life and freedom for their lives, it's a pretty deal? Isn't it? Will it really be? The Gangster's Crush is a story- about love, trust, loyalty, and revenge It is available on Amazon, please support me. Disclaimer: Adult scenes, 16+ I hope you like the story if you do please share it with your friends. Word count 20,000 - 23,000~
I Can't Let You Go (COMPLETED) by Miss_dreamy_writer
31 parts Complete Mature
#1 - Muslim | 16-11-2024 #1 - Urdu | 11-11-2024 #2 - Desi | 16-11-2024 #3 - Strong Female Lead | 16-11-2024 #4 - Replaced Bride | 30-10-2024 #8 - Love Life | 11-11-2024 #36 - Happily Ever After | 27-10-2024 #14 - Family Issues | 31-03-2025 #75 - Muslim Love Story | 3-10-2024 *** I stormed towards him, anger blurring my sights. The moment I was in front of him, I grabbed hold of his collar with my both hands. As I yell, "Are you cheating on me, Shahzain?" Seems like I took him by surprise, it took him a whole minute to realize what was happening right now. And the moment he did, he loosen my hold on him and pushed me, which had me stumbling back. "Even if I do, it shouldn't matter. I was forced into this marriage, Sobia." He yells back. "I didn't have a choice. But you had. You shouldn't have agreed to this marriage." Only if he knew, all my life it wasn't me who got to select the choice. Neither is this one, the most important one in my life. "I won't tolerate this. Either you leave me or leave her." I stated, anger clouding my senses. He walked towards me and took a hold of my chin in his hand and stated clearly. "And where's the fun in that? You ruined my life. I promised to ruin you till death do us a part." I pushed him hard. I had already suffered much from my so-called family. And I refused to get suffered by my husband. It's all about the limit. The moment I had my limit of misery and pain, I will end all of this. "Are you sure, it's not the other way around?" A humorless chuckle escapes my lips, as my darkest shade of eyes met his grey ones. "Also, just wanted to correct you, my dearest husband. You can't ruin what's already ruined, Shahzain." "And if I find out that you kept meeting her behind my back. I will ruin you and that lover of yours." With that I stormed out of our room, making up my mind.
You may also like
Slide 1 of 9
OLD VERSION ✾Balance✾ (Lloyd Garmadon x Fem!Reader) cover
Mystery: Unspoken truth cover
OCCULT VISION {COMPLETED} ✔️✔️ cover
I Will Be The Strongest!! cover
THE GANGSTER'S CRUSH- FAMILY OVER FREEDOM (SAMPLE) cover
ONE STEP(Dark Indian Romance)😏 cover
Tangled ✓ cover
I Can't Let You Go (COMPLETED) cover
With CEO Vyom (Complete) cover

OLD VERSION ✾Balance✾ (Lloyd Garmadon x Fem!Reader)

23 parts Complete

The balance of life and death must be maintained. For if a life should be given, a life must be taken. If there must be light, there must be darkness. If there is good, there must be evil. That's been (Y/n)'s job from the day she was born. To maintain the balance of good and evil has been a life long duty she had to the world. There have always been rules to her powers. 1. She cannot tip the balance, no matter how much she may wish she could, she can't, for the sake of the world. 2. She cannot be involved within the events that could mean good and bad. Even in the most dire of situations, she can not get involved, even if it means people have to die. 3. Never, never, ever, fall in love. Falling in love will only be an inconvenience for her, for there were many people around that desire her powers, not her. But there were always loopholes. 1. She may tip the balance if the other side were to take action. For if the forces of evil were take an action beyond good's power, she may take action. 2. She may only observe what events will take place, but nothing said she couldn't say what will take place. 3. There is no loop hole. She will just have to figure that out herself.