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
| test_arrs = { | |
| "arr1": ["cranberry","crawfish","crap"], # "cra" | |
| "arr2": ["parrot", "poodle", "fish"], # "" | |
| "arr3": [], # "error" | |
| "arr4": ["", "", ""], # "" | |
| "arr5": ["ab1d", "ab2d", "ab3d"], # "ab" | |
| } | |
| def longest_prefix(arr): | |
| prefix = "" |
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
| // are there best practices that should apply here? | |
| // my solution | |
| const showEl = document.getElementById("show-item") | |
| const itemEl = document.getElementById("item") | |
| showEl.addEventListener("click", function() { | |
| item.style.display = "block" | |
| }) |
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 celebrity = { | |
| first: 'Robert', | |
| last: 'Martin', | |
| nickName: 'Uncle Bob', | |
| fullName() { | |
| const {first, last, nickName} = this; | |
| console.log(`${first} ${nickName ? `[${nickName}] ` : ''}${last}`) | |
| } | |
| } |
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 | |
| // call by value | |
| function square($val) { | |
| $val = $val * $val; | |
| return $val; | |
| } | |
| $num = 7; | |
| print($num); |
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 | |
| function greet($username) { | |
| print_r("hello, " . $username); | |
| } | |
| $username = $_GET['name'] ?? 'friend'; | |
| greet($username); | |
| ?> |
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
| $num = 42; | |
| $msg = ($num % 2 == 0) ? "Even" : "Odd"; | |
| echo "$msg \n"; |
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
| /* Example 1: class selectors */ | |
| .nav-links { | |
| list-style: none; | |
| } | |
| .nav-link { | |
| color: purple; | |
| font-size: 1.5rem; | |
| text-decoration: none; | |
| } |
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
| .sample { | |
| height: 300px; | |
| width: 100%; | |
| display: flex; | |
| justify-content: center; | |
| } | |
| .sample > a { | |
| display: inline-block; | |
| height: 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
| width = 100 | |
| length = 75 | |
| height = 50 | |
| console.log(width, length, height) | |
| // 100 75 50 | |
| console.log({width, length, height}) | |
| // {width: 100, length: 75, height: 50} |
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
| { this.state.display && <h1>Display True!</h1> } | |
| { !this.state.display && <h1>Display False!</h1> } | |
| { (this.state.counter === 5) && <h1>Display Five!</h1> } |
NewerOlder