{{ message }}

Instantly share code, notes, and snippets.

🏠
Working from home

# Nicki Hastings nickihastings

🏠
Working from home
Created Mar 22, 2018
Check if a value is classified as a boolean primitive. Return true or false. Boolean primitives are true and false.
View boo-who.js
 function booWho(bool) { // What is the new fad diet for ghost developers? The Boolean. //check if the value 'bool' is strictly true or false, this means the value is a Boolean Primitive and should return true. //Everything else should return false. if(bool === true || bool === false){ return true; } else { return false; }
Last active Apr 12, 2021
 ' . print_r( \$GLOBALS[ 'menu' ], TRUE) . ''; } ?>
Created Feb 18, 2020
Duplicate a post created with Formidable Forms frontend post submission, so that it is available in all languages. Needs WPML.
Created Apr 9, 2018
Design a cash register drawer function checkCashRegister() that accepts purchase price as the first argument (price), payment as the second argument (cash), and cash-in-drawer (cid) as the third argument. cid is a 2D array listing available currency. Return the string "Insufficient Funds" if cash-in-drawer is less than the change due. Return the…
View exact-change.js
 function checkCashRegister(price, cash, cid) { //change all decimals to whole numbers for ease //First work out how much change is needed var change = (cash * 100) - (price * 100); //Next work out how much cash there is in the cash register using //reduce to add all the values and turn to whole numbers var totalCash = cid.reduce(function(accum, current){ accum = accum + (current[1]*100);
Created Apr 17, 2018
Given an array arr, find element pairs whose sum equal the second argument arg and return the sum of their indices. If multiple pairs are possible that have the same numeric elements but different indices, return the smallest sum of indices. Once an element has been used, it cannot be reused to pair with another. For example pairwise([7, 9, 11, …
View pairwise.js
 function pairwise(arr, arg) { //if its an empty array return 0 if(arr.length === 0){ return 0; } //reduce the array by looping over the array and checking if the //sum of the current element and another element = the argument. //if they match and the indexes of both are different, add the indexes to //the output array. var pairs = arr.reduce(function(accum, curr, index, array){
Last active Apr 15, 2020
How to hide an admin menu in WordPress based on a user role
Last active Feb 18, 2020 — forked from fredrikwoll/aux-functions.php
Programmatically duplicating a WordPress post
Created Oct 10, 2019
Use lookaheads in the pwRegex to match passwords that are greater than 5 characters long and have two consecutive digits.