๐๐ฎ๐๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐๐ผ๐ป๐๐ฟ๐ผ๐น ๐๐น๐ผ๐ ๐ฎ๐ป๐ฑ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐
Learn how JavaScript manages logic and repetition.
For Loops Use for loops to repeat tasks.
- Initialization: sets your starting point.
- Condition: decides if the loop keeps running.
- Afterthought: changes the counter after each turn.
Example: for (let i = 1; i <= 5; i++) { console.log(i); }
do...while Loops These loops run the code first. They check the condition second. The code runs at least once.
Example: let x = 10; do { console.log("Hello"); } while (x < 5);
Functions Functions keep your code clean.
- Parameters: names used inside the function.
- Arguments: actual values you send to the function.
Example: function add(a, b) { console.log(a + b); } add(10, 20);
Interview Tip Pass only one argument to a function expecting two. add(10); The result is NaN. The second value is undefined.
Source: https://www.geeksforgeeks.org/javascript/javascript-for-loop/ Optional learning community: https://dev.to/ezhil_abinayak_e38eec8fb/exploring-javascript-control-flow-and-functions-3m5k