-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5ab95d
commit 4b3e274
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const isEven = function (num) { | ||
return num % 2 === 0; | ||
} | ||
|
||
const tenIsEven = isEven(10); | ||
const elevenIsEven = isEven(11); | ||
|
||
console.log(tenIsEven); | ||
console.log(elevenIsEven); | ||
|
||
/*We can simplify the above code using them directly, | ||
instead of setting to them to new variables!*/ | ||
|
||
const isNewEven = function (num) { //Renaming varialble to avoid syntax error! | ||
return num % 2 === 0; | ||
} | ||
|
||
console.log(isNewEven(10)); | ||
console.log(isNewEven(11)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const sayHello = function (name) { // Create a function with a parameter "Name" | ||
console.log("Hello, " + name); //Log the string within the function | ||
} | ||
|
||
sayHello("Wes"); //Delcare the function with a set parameter | ||
sayHello("Lina");//Again | ||
sayHello("Elmtree");//and again!! | ||
|
||
//This is how you return a parameter to a variable the log it to the console. | ||
const returnSayHello = function (name) { // create a function | ||
return "Hello, " + name; // return a conditon | ||
} | ||
|
||
const greeting = returnSayHello("Peter"); // Create a variable to hold the function return | ||
console.log(greeting); // log the variable |