I've just completed a front-end coding challenge from @frontendmentor! 🎉
You can see my solution here: https://t.co/67YBV0uVaj
Any suggestions on how I can improve are welcome!
the condition component is assessed. The loop continues if the condition is true; if not, it ends.
At the conclusion of each iteration, the increment/decrement function is used to update the loop control variable until it eventually satisfies the termination condition.
Day 20/20 of #20daysinFrontendwithAA
Finally 🥳 @AfricaAgility
For loop
A "for loop" in JavaScript is a control flow statement that enables you to repeatedly run a block of code in response to a given condition. In JavaScript, a for loop has the following syntax:
for (starting position; condition; increment/decrement) {
// code to be executed in each iteration
}
At the beginning of the loop, the starting position section is just once executed. It is used to set up a loop control variable.
Prior to each iteration,
(such as "click," "mouseout," "mouseover," etc.), the listener is the function that should be called when the given event takes place, and the element is the object to which you want to attach the event listener.
Day 19 of #20daysinFrontendwithAA@AfricaAgility
Event listener in JavaScript
The event listener in JavaScript is a function that is attached to an element and "listens" for a particular event to happen. Events include a variety of interactions, including clicks, mouseovers,
mouseouts, and others.
The following is the fundamental syntax for adding an event listener in JavaScript:
element.addEventListener(eventType, listener);
EventType is a string that identifies the kind of event you want to listen for
7. When certain conditions are met, "early return" enables you to return a value from a function.
JavaScript functions are more flexible and can be used to better control data flow when the return keyword is used.
Day 18 of #20daysinFrontendwithAA
Two more days to go 🥳🥳 @AfricaAgility
In JavaScript, the return keyword is used in functions to send a value back to the calling code. A function immediately terminates when it comes across a return statement and stops running.
3. The default return value for functions is undefined, whether they have a return statement or not.
5. The output of functions can include objects and arrays, which are more complex data structures.
6. Functions can also return other functions.
A return statement in a function enables it to pass a value back to the code that invoked it. You can use or assign the returned value to a variable. Example:
function sum(num1, num2) {
return num1 + num2;
};
sum(2, 3);
Day 17 of #20daysinFrontendwithAA@AfricaAgility
Function in JavaScript
A function is a reusable section of code that executes a single task or group of related actions. Without having to repeatedly write the same code, it enables you to specify a series of actions that may..
function name(params) {
// code to be executed
}
You "call" a function by using its name followed by parenthesis to use it and run the code inside it. If the function requires arguments, you can pass them in parentheses as well.