Hello coders!!π
So, this is my Part-7 of JavaScript for Beginners!π
Lemme remind you all, from Part 1 to Part-6 we learned about:
Printing statements, Variables in JS, and Arithmetic Operators.
Incrementing numbers, Decrementing numbers, Shortcuts :
(*=, /=)
, Add 1 to number, and Escape sequences in strings.Concatenating strings with plus operator, Concatenating strings with plus equals operator, Constructing strings with variables, Activity!!.
Find the Length of the string, Bracket Notations to find the characters of strings, and Bracket Notations to find the last letter!
Word Blanks!π³ (by using functions), Challenge!π©βπ» `(On Functions)
Store multiple things with Arrays!, Nested Arrays in JS!, Access array with data indexes!, Modify Array data with Indexes!, Access Multi-Dimensional arrays!!.
Manipulate Arrays with
push()
, Manipulate Arrays withpop()
, Manipulate arrays withshift()
, Manipulate arrays withunshift()
, Shopping list[]π.Functions in JS!, Passing values in functions, Global scopeπ and Functions.π, Local Scope and Functions, Global and Local Scopes!!ππ.
So, this is all we have learned till now but in this blog, we'll learn much more!!π
Exited??
Topic:
Return values by Return statement!!π
// Return function
function helloCoders(number) {
//created a function
return number - 9; //returning
}
console.log(helloCoders(59)); //output:59 - 9 = 50
Output:
50
Assignment for a return value!!π±
var complete = 0; // Global scope
function completed(number) {
//Created a function
return (number + 20) / 3;
}
console.log((complete = completed(100)));
Output:
40
2nd Example:
var changed = 0;
function change(num) {
return (num + 5) / 3;
}
console.log((changed = change(10)));
Output:
5
3rd Example:
var processed = 0;
function processArg(num) {
return (num + 3) / 5;
}
console.log((processed = processArg(7)));
Output:
2
Return statements (+, -)β
Example of adding:
function myNum(num) {
return num + 800;
}
console.log(myNum(1000));
Output:
1800
Example of subtracting:
function subtractNum(num) {
return num - 30;
}
console.log(subtractNum(100));
Output:
70
So, that is it for today guys!! and also these were several examples for return statements!!π
Hopefully, you have learned something new!!
Motivation for Today: "When you have a dream you have got to grab it and never let it go!!π"
And I will see you all again in the next blog till then take care and goodbye!!β₯