Skip to content

Instantly share code, notes, and snippets.

@Oletem
Oletem / .htm
Created February 5, 2018 11:40
<form>
<th>
<label for = "Games">Games</label>
<tr>
<td>
<select id = "games">
@Oletem
Oletem / .php
Created January 11, 2018 12:41
First, we create page-custom.php. Second, in the head we comment the name of template, that will be displayed and available to select in page attributes template => custom template selector. Then, in query, created in custom-page.php we can specify, what content will be displayed on this page More refernce: https://codex.wordpress.org/Class_Refe…
<?php
/**
* Template Name: Custom Template - how WP knows what the page is
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<article <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
@Oletem
Oletem / .js
Created January 10, 2018 15:44
:beginner: Basic Code Solution:
function getIndexToIns(arr, num) {
arr.sort(function(a, b) {
return a - b;
});
for (var a = 0; a < arr.length; a++) {
if (arr[a] >= num)
return a;
}
@Oletem
Oletem / .js
Created January 10, 2018 13:53
Examples Examples of falsy values in JavaScript (which translate to false and thus bypass the if block): if (false) if (null) if (undefined) if (0) if (NaN) if ('') if ("") if (document.all) [1] [1] document.all has been used for browser detection in the past and the HTML specification defines a willful violation of the ECMAScript standard here …
_
@Oletem
Oletem / .js
Created January 10, 2018 13:25
The indexOf() method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found. Note: For the Array method, see Array.prototype.indexOf(). Syntax str.indexOf(searchValue[, fromIndex]) Parameters searchValue A string representing the va…
The indexOf() method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found.
Note: For the Array method, see Array.prototype.indexOf().
Syntax
str.indexOf(searchValue[, fromIndex])
Parameters
searchValue
A string representing the value to search for.
fromIndex Optional
An integer representing the index at which to start the search; the default value is 0. For fromIndex values lower than 0 or greater than str.length, the search starts at index 0 and str.length respectively.
@Oletem
Oletem / isNaN.js
Last active October 10, 2017 08:36
isNaN() Method. The Number.isNaN() method determines whether a value is NaN (Not-A-Number). This method returns true if the value is of the type Number, and equates to NaN. Otherwise it returns false. Number.isNaN() is different from the global isNaN() function. The global isNaN() function converts the tested value to a Number, then tests it. Nu…
Number.isNaN(123) //false
Number.isNaN(-1.23) //false
Number.isNaN(5-2) //false
Number.isNaN(0) //false
Number.isNaN('123') //false
Number.isNaN('Hello') //false
Number.isNaN('2005/12/12') //false
Number.isNaN('') //false
Number.isNaN(true) //false
Number.isNaN(undefined) //false
@Oletem
Oletem / head_cut.js
Created October 8, 2017 17:35
Return the remaining elements of an array after chopping off n elements from the head. The head means the beginning of the array, or the zeroth index. Remember to use Read-Search-Ask if you get stuck. Write your own code. Here are some helpful links: Array.prototype.slice() Array.prototype.splice()
function slasher(arr, howMany) {
return arr.slice(howMany);
}
slasher([1, 2, 3], 2);
@Oletem
Oletem / join.js
Created October 1, 2017 12:37
We can use the join method to join each element of an array into a string separated by whatever delimiter you provide as an argument. The following is an example of using join to join all of the elements of an array into a string with all the elements separated by word and: var veggies = ["Celery", "Radish", "Carrot", "Potato"]; var salad = vegg…
var joinMe = ["Split","me","into","an","array"];
var joinedString = '';
// Only change code below this line.
joinedString = joinMe.join(" ");
@Oletem
Oletem / concat.js
Created October 1, 2017 12:35
concat can be used to merge the contents of two arrays into one. concat takes an array as an argument and returns a new array with the elements of this array concatenated onto the end. Here is an example of concat being used to concatenate otherArray onto the end of oldArray: newArray = oldArray.concat(otherArray); Use .concat() to concatenate c…
var oldArray = [1,2,3];
var newArray = [];
var concatMe = [4,5,6];
// Only change code below this line.
newArray = oldArray.concat(concatMe);
@Oletem
Oletem / Gear.js
Created September 30, 2017 18:04
Objects have their own attributes, called properties, and their own functions, called methods. In the previous challenges, we used the this keyword to reference public properties of the current object. We can also create private properties and private methods, which aren't accessible from outside the object. To do this, we create the variable in…
var Car = function() {
// this is a private variable
var speed = 10;
// these are public methods
this.accelerate = function(change) {
speed += change;
};