This file contains hidden or 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
function generate(number) { | |
return number * 2; | |
} | |
generate(2) // returns 4 | |
generate(2) // returns 4 |
This file contains hidden or 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
function generate(number) { | |
return number * Math.random(); | |
} | |
generate(number) // returns 1.2770887888419167 | |
generate(number) // returns 0.3149105063079531 |
This file contains hidden or 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
// Traditional Javascript | |
function total(tax) { | |
return function(subtotal) { | |
return subtotal + ((subtotal \* tax)/100); | |
} | |
} | |
// ES6 | |
const total = tax => subtotal => subtotal + ((subtotal * tax)/100); |
This file contains hidden or 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
function total(tax) { | |
return function(subtotal) { | |
return subtotal + ((subtotal * tax)/100); | |
} | |
} | |
const amount = total(18); | |
const item1 = amount(100); // Returns 118 | |
const item2 = amount(120); // Returns 141.6 |
This file contains hidden or 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
function total(tax) { | |
return function(subtotal) { | |
return subtotal + ((subtotal * tax)/100); | |
} | |
} |
This file contains hidden or 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
function total(subtotal, tax) { | |
return subtotal + ((subtotal * tax)/100); | |
} | |
const item1 = total(100, 18); // Returns 118 | |
const item2 = total(120, 18); // Returns 141.6 | |
const item2 = total(150, 18); // Returns 177 |
This file contains hidden or 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
function total(subtotal, tax) { | |
return subtotal + ((subtotal * tax)/100); | |
} |
This file contains hidden or 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
<?php | |
namespace App; | |
use App\Model; | |
class Post extends Model | |
{ | |
} |
This file contains hidden or 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
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model as CoreModel; | |
class Model extends CoreModel | |
{ | |
/** | |
* Returns the last record on posts table |
This file contains hidden or 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
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Post extends Model | |
{ | |
/** | |
* Returns the last record on posts table |