Amena ๐Ÿ’ซ
Amena

Follow

Amena

Follow
JavaScript for Beginners!   Part-7๐Ÿ

JavaScript for Beginners! Part-7๐Ÿ

Amena ๐Ÿ’ซ's photo
Amena ๐Ÿ’ซ
ยทOct 25, 2022ยท

2 min read

Play this article

Table of contents

  • Return values by Return statement!!๐Ÿƒ

Hello coders!!๐Ÿ‘‹

So, this is my Part-7 of JavaScript for Beginners!๐Ÿ

Lemme remind you all, from Part-1 to Part-6 we had learned about:

  • Printing statements, Variables in JS, Arithmetic Operators.
  • Incrementing numbers, Decrementing numbers, Shortcuts :(*=, /=), Add 1 to number,Escape sequences in strings.
  • Concatenating strings with plus operator, Concatenating strings with plus equals operator, Constructing strings with variables, Activity!!.
  • Find Length of string, Bracket Notations to find the characters of strings, 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 with pop(), Manipulate arrays with shift(), Manipulate arrays with unshift(), 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 had 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 statement!!๐Ÿ˜‰

Hopefully you had learned something new!!

Motivation for Today: "When you have a dream you have got to grab and never let it go!!๐Ÿ˜‰"

And I will see you all again in the nest blog till then take care and goodbyee!!โ™ฅ

ย 
Share this