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 Champion(category = 'Champion') { | |
| this.category = category; | |
| this.sayHi = function() { console.log(`Hey, a ${this.category} is here`) }; | |
| }; | |
| function Warrior() { | |
| Champion.call(this,'Warrior'); | |
| } | |
| function Dwarf() { |
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 Champion(category = 'Champion') { | |
| this.category = category; | |
| }; | |
| function Warrior() { | |
| Champion.call(this,'Warrior'); | |
| } | |
| function Dwarf() { | |
| Champion.call(this,'Dwarf'); |
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
| alertDialogBuilder | |
| .setMessage("Click yes to exit!") | |
| .setCancelable(false) | |
| .setPositiveButton("Yes",new DialogInterface.OnClickListener() { | |
| public void onClick(DialogInterface dialog,int id) { | |
| // Stuff | |
| } | |
| }) | |
| .setNegativeButton("No",new DialogInterface.OnClickListener() { | |
| public void onClick(DialogInterface dialog,int id) { |
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
| // Using ES6 arrow functions | |
| // Returns true if all even numbers doubled from @numbers are above 5 | |
| function doubleEvenNumbers(numbers) { | |
| return numbers | |
| .filter(x => x % 2 == 0) // Odd numbers removed | |
| .map(x => x*2) // Even numbers doubled | |
| .every(x => x > 5); // Are they all above 5 ? | |
| } |
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
| // Using ES6 arrow functions | |
| // Returns true if all even numbers doubled from @numbers are above 5 | |
| function doubleEvenNumbersES6(numbers) { | |
| return numbers.filter(x => x % 2 == 0).map(x => x*2).every(x => x > 5); | |
| } | |
| console.log(doubleEvenNumbersES6([3,4,5,6])) | |
| // => True, because doubled array is [8,12] |
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
| // Hypothetical NLP function - ES6 includes used | |
| function isTextFunEnough(text) { | |
| if(text.length == 0 || text.includes('angry')) | |
| return false; | |
| return text.includes('lol'); | |
| } | |
| console.log(isTextFunEnough('This article is so epic lol') ? 'Definitely fun, LMAO':'Not very funny...'); | |
| // => Definitely fun, LMAO |
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
| // Hypothetical NLP function - ES6 includes used | |
| function isTextFunEnough(text) { | |
| if(text.length == 0) { | |
| return false; | |
| } | |
| else if(text.includes('lol')) { | |
| if(text.includes('angry')) | |
| return false; | |
| else | |
| return true; |
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
| var OPTIONS = { | |
| 'GRAYSCALE': 1, 'SEPIA': 2, 'HIGH-RES': 4, 'LOW-RES': 8 | |
| }; | |
| function setCameraSettings(options) { | |
| if( options & OPTIONS['GRAYSCALE'] ) | |
| console.log('GRAYSCALE activated'); | |
| if( options & OPTIONS['SEPIA'] ) | |
| console.log('SEPIA activated'); | |
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
| var OPTIONS = { | |
| 'GRAYSCALE': 1, 'SEPIA': 2, 'HIGH-RES': 3, 'LOW-RES': 4 | |
| }; | |
| function setCameraSettings(options) { | |
| if(options.includes(OPTIONS['GRAYSCALE'])) | |
| console.log('GRAYSCALE activated'); | |
| if(options.includes(OPTIONS['SEPIA'])) | |
| console.log('SEPIA activated'); | |
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
| let x = [1,2,3,4,5]; | |
| let y = x.filter( element => element % 2 == 0).map(element => element*2); | |
| console.log(y); | |
| // => [4,8] |