- Creating arrays - https://repl.it/@nbeers22/Creating-arrays-drill
- Adding array items - https://repl.it/@nbeers22/Adding-array-items-drills
- Accessing array items - https://repl.it/@nbeers22/Accessing-array-items-drill
- Array length & access - https://repl.it/@nbeers22/Array-length-and-access-drill
- Array Copying I - https://repl.it/@nbeers22/Array-copying-I-drill
- Array Copying II - https://repl.it/@nbeers22/Array-copying-II-drill
- Squares with map - https://repl.it/@nbeers22/Squares-with-map-drill
- Sort - https://repl.it/@nbeers22/Sort-drill
- Filter - https://repl.it/@nbeers22/Filter-drill
- Find - https://repl.it/@nbeers22/Find-drill
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
# Solution for Challenge: Pig-latin. Started 2014-09-16T15:13:49+00:00 | |
# Script: CONVERT TO PIG LATIN | |
# Iteration One: CONVERT SINGLE WORD | |
# GET a word from user input. | |
# IF the word starts with a vowel, don't change it. | |
# ELSE replace the word with its pig latin equivalent. | |
# GET all of the consonants before the first vowel in the word. |
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
<div class="carousel-inner" role="listbox"> | |
<?php query_posts("posts_per_page=1&post_type=carousel"); ?> | |
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> | |
<div class="item active"> | |
<?php the_post_thumbnail('full', array( 'class' => "img-responsive")); ?> | |
</div> | |
<?php endwhile; ?> |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 | |
// remove some meta tags from WordPress | |
remove_action('wp_head', 'wp_generator'); | |
function remove_dns_prefetch( $hints, $relation_type ) { | |
if ( 'dns-prefetch' === $relation_type ) { | |
return array_diff( wp_dependencies_unique_hosts(), $hints ); | |
} | |
return $hints; | |
} |
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 | |
// Remove custom post type name from URL for special posts | |
function remove_cpt_slug( $post_link, $post, $leavename ) { | |
if ( 'special' != $post->post_type || 'publish' != $post->post_status ) { | |
return $post_link; | |
} | |
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); |
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
// Create a function called wisePerson that takes 2 arguments: wiseType and whatToSay. | |
// This function takes a block of text and presents it as a quote from the wise person. | |
// wiseType is the person the quote will be attributed to, and whatToSay is what the wise person will be quoted as saying. | |
// When called like this: wisePerson('goat', 'Hello world') should return the string 'A wise goat once said: "Hello world".' | |
const wisePerson = (wiseType, whatToSay) => `A wise ${wiseType} once said: "${whatToSay}"` | |
// Create a function that takes a single argument: whatToShout. |
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
// Create a function called computeArea that takes two arguments: width and height. | |
// It returns the area of a rectangle whose width is width and height is height. | |
// So computeArea(2, 2) would return 4, and computeArea(3, 5) would return 15. | |
const computeArea = (width, height) => width * height; | |
// Create 2 functions, one called celsToFahr that converts Celsius to Fahrenheit and | |
// another called fahrToCels that converts Fahrenheit to Celsius. celsToFahr takes one | |
// argument, celsTemp, and fahrToCels takes one argument, fahrTemp. | |
// [°F] = [°C] × 9⁄5 + 32 | |
// [°C] = ([°F] − 32) × 5⁄9 |
- Max and min (without sort) - https://repl.it/@nbeers22/min-and-max-without-sort-drill
- Compute the average - https://repl.it/@nbeers22/average-drill
- FizzBuzz - https://repl.it/@nbeers22/fizzbuzz-drill-js
Questions: What is scope? Your explanation should include the idea of global vs. block scope. Why are global variables avoided? Explain JavaScript's strict mode What are side effects, and what is a pure function?
- Scope determines the visibility/accessibility of variables, objects, and funcitons within the code. JavaScript has global scope, function scope, and with the addition of ES6, block scope using let and const. Global variables are available everywhere but are typically viewed as bad practice because they can produce unintended results down the line. They also can be a performance hit, because when JavaScript is compiled it checks for variable
OlderNewer