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
| import time | |
| start_time = time.time() | |
| for loop in range(1, 100000000): | |
| pass | |
| print('FINISHED EXECUTION') | |
| print("--- %s seconds ---" % round(time.time() - start_time, 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
| const randomBoolean = () => Math.random() >= 0.5; | |
| console.log(randomBoolean()); |
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
| const week = (date) => date.getDay()% 6 !== 0; | |
| console.log(week(new Date(2021, 0, 11))); // Result: true (Monday) | |
| console.log(week(new Date(2021, 0, 15))); // Result: false (Sunday) |
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
| const reverse = str => str.split('').reverse().join(''); | |
| console.log(reverse('cake is yummy')); | |
| // Result: 'ymmuy si ekac' |
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
| const isBrowserTabInView = () => document.hidden; | |
| isBrowserTabInView(); |
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
| const even = num => num % 2 === 0; | |
| console.log(even(2)); // true | |
| console.log(even(3)); // false |
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
| const hex = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, "0")}`; | |
| console.log(hex()); |
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
| const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches | |
| console.log(isDarkMode) // Result: True or False |
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
| const elementIsInFocus = (el) => (el === document.activeElement); | |
| elementIsInFocus(anyElement) // Result: If it is in focus, it will return True, otherwise it will return False |
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
| const touchSupported = () => { | |
| (‘ontouchstart’ in window || window.DocumentTouch && document instanceof window.DocumentTouch); | |
| } | |
| console.log(touchSupported()); // Result: If touch event is supported, it will return True, otherwise it will return False |