Search

Search Code by entering the text above.
javascript
...
js using recursion to create a range of numbers

in this we will create a function that calls its self to add to an array a range of numbers

4:25 am, November 25, 2019
javascript
...
Using the Spread Operator to Evaluate Arrays In-Place Tests

My tests using the Spread Operator rather than the apply function. In the 1st function show_max_array i use the apply operator to convert the array into comma seperated values. In the show_max_array..

1:02 am, October 14, 2019
javascript
...
Using the rest operator to pass in a variable amount of arguments

If you don't know how many parameters you will need in your function you can use the rest operator to pass them in. ...

5:49 am, October 1, 2019
javascript
...
Default Parameters for Functions

You can pass in default parameters for functions so that if the function is used with no parameter it will use the default one.

5:23 am, October 1, 2019
javascript
...
Complex Arrow Function Example

Here is an example using a Complex or Higher Order arrow function, which slightly reduces the amount of code lines used. This should return the square root of all positive integers passed into it.

5:14 am, October 1, 2019
javascript
...
Writing Arrow Functions with Parameters

you can pass parameters to arrow functions as well as shown in the following demo, these functions are only meant to be used once where normal functions can be re-used.

12:36 am, October 1, 2019
javascript
...
using arrow functions to convert small functions into one line statement functions

in this exercise i will take a function variable and write it in one line using the arrow function

12:09 am, October 1, 2019
javascript
...
Prevent Object Mutation

This shows how you can lock an object so its content cannot be modified. if you comment out the line Object.freeze(my_object); it will allow it to be modified again.

11:16 pm, September 30, 2019
javascript
...
Changing an array declared with const

a const means that you cannot re-declare the variable name, but you can still mutate an array content that is declared as a const. so you can see in the following example that even though the array is..

6:17 am, September 30, 2019
javascript
...
using let and const example

This example uses let and const rather than just vars, let can only be declaired once rather than overwritten like vars and const is a read only variable so it cant be changed. 

4:55 am, September 27, 2019
javascript
...
using let rather than var

Using let rather than var and use strict can avoid some overwriting of variables i will write a function here that shows how let throws an error. This function now gives an error in the console. Uncau..

4:18 am, September 27, 2019
javascript
...
Use Multiple Conditional (Ternary) Operators

I actually find if then statements much easier to read than these ones, but these seem more efficient. 

3:18 am, September 27, 2019
javascript
...
js - Use the Conditional (Ternary) Operator

this statement can be used instead of if this else that statements. to me it makes it look a bit more complex when reading it. this is the basic syntax. condition ? statement-if-true : statement-if-fa..

6:23 am, September 24, 2019
javascript
...
Use the parseInt Function with a Radix

This is the same as the parseint function, but you can also specify a base for the number which can be between 2 - 36. 2 is binary. Zeros and Ones. I think base 10 is the normal numbering system, but ..

6:14 am, September 24, 2019
javascript
...
Using parseInt in a function to return an integer or not

this function uses the parseInt function to return a proper integer or an error code if it can't. So this demo should return NaN for the Not an Int (x1235) and The int for the 00001235. I think that N..

5:57 am, September 24, 2019
javascript
...
Generate Random Whole Numbers within a Range

My testing for generating a random whole number within a range... 🤞 While the solution here works, it just loops until it gets a random number that is lower than the max, so not sure if this is th..

5:15 am, September 24, 2019
javascript
...
split a string into an array using split javascript

this will split the string into an array based on the spaces inbetween words. you can split it based on any character, for example if you had words in csv comma format you could use the second example..

4:47 am, September 16, 2019
javascript
...
get the current url in javascript

this will get the current address add it to a variable and show it on the result element

3:47 am, September 13, 2019
css
...
Radial Click Effect

shows the radial click effect like in the material design, so when you click a button it will show a click at that area with a nice animation. Uses CSS and javascript to generate this effect.

1:13 am, September 4, 2019
js
...
Generate Random Whole Numbers with JavaScript Function

generate a random whole number function with test buttons

6:20 am, August 26, 2019
js
...
Generate Random Fractions with JavaScript

generate a random fraction and add it to result when clicking a button

6:09 am, August 26, 2019
js
...
FCC - Basic: Profile Lookup

my solution to the FCC Basic js Profile Lookup, with added results area and button to run the function.

5:38 am, August 26, 2019
javascript
...
Do While Loop

showing how to use a do while loop, i don't use these ones very often usually just a for loop.

11:26 pm, August 25, 2019
javascript
...
for loop through an array with javascript

looping through an array with javascript using a basic for loop

12:18 am, August 23, 2019
javascript
...
tinymce remove auto p tags setting

this is the setting to remove the automatic p tag's when pressing enter and forces the use of br tags instead which can also be toggled, if you dont want it to add anything.

6:15 am, August 13, 2019
javascript
...
get the dimensions of an image with javascript

this will show the height and width of an image using javascript

5:55 am, August 13, 2019
javascript
...
basic for loop odd numbers

a basic for loop with odd numbers adding to an array

6:20 am, July 31, 2019
javascript
...
check if something is an array

this function will check if something is an array

5:26 am, July 31, 2019
javascript
...
getType function for js

this function returns the type of item, array object string number etc

11:50 pm, July 29, 2019
javascript
...
Objects in javascript

creating and using an object in javascript, the full version of this testing is on codepen

11:25 pm, July 29, 2019
javascript
...
card counting example from fcc

here is a solved version of the card counting function from free code camp you can test it using console log.

2:00 am, July 29, 2019
javascript
...
using switch with multiple identical cases

this can be used if you have several outcomes where the return value will be the same by omitting the break from the cases before the final

1:32 am, July 29, 2019
javascript
...
using switch in a function

This shows an example using the switch to select multiple options in a function, you can return from the switch with break, or you can end the whole function with return.

11:19 pm, July 28, 2019
javascript
...
js function to calculate golf scores

this function will return the score name depending on the par and strokes for golf

1:48 am, July 24, 2019
javascript
...
compare non equality function

this will check if two values are not equal

11:15 pm, July 23, 2019
javascript
...
compare equality function

this will check if two values are exactly equal

10:57 pm, July 23, 2019
javascript
...
JS Using typeof to check on string types

you can use the typeof operator to check what kind of variables you have.

2:38 am, July 23, 2019
javascript
...
testing equality

showing the difference between == and === operators

5:57 am, July 22, 2019
javascript
...
defining a variable inside a function without using var will create a global variable

here is an example showing a variable defined within a function showing how it becomes a global variable if not defined with var

5:15 am, July 22, 2019
javascript
...
add something to the start of an array with unshift

unshift is the opposite of push where push adds to the end of an array unshift will add to the start of the array.

2:40 am, July 19, 2019
javascript
...
remove the first element in an array with shift

like pop but shift does the 1st element in an array

2:37 am, July 19, 2019
javascript
...
document ready javascript standalone version no jquery

this is a version of a dom ready or document ready that does not require jquery

1:14 am, July 17, 2019
javascript
...
add a class to a div with an id javascript

a one liner to add a class name to an element with a specific id, for this to run it seems to need a document ready.

1:11 am, July 17, 2019
javascript
...
using local storage rather than cookies to store data (localStorage)

you can see what is stored in local storage by typing this into your browser console. localStorage Adding something You can add something to local storage by using the setItem function.

11:31 pm, July 16, 2019
javascript
...
remove something from the end of an array with pop

pop is the opposite of push and will remove the last item in an array, it also returns the value so you can assign it to a variable

5:58 am, July 16, 2019
javascript
...
add something to the end of an array with push

you can easily add to the end of a javascript array with the .push function.

5:49 am, July 16, 2019
javascript
...
Multidimensional Array

sounds complex, but it's not really here is an example of a Multidimensional Array in javascript. It's just one array nested in another.

4:50 am, July 16, 2019
javascript
...
get the last letter of a string

you can use the .length and the index of a string to get its last value

4:40 am, July 16, 2019
javascript
...
accessing part of a variable using its index

you can access part of a string variable using its index[1]

4:34 am, July 16, 2019
javascript
...
js check the length of a string

using the javascript .length property

2:04 am, July 16, 2019
html
...
Dropdown Box with Searchable Text

Here we have a dropdown select box, that you can type into to search the available options. No Javascript Required for this the browser does all the work. Press into the text box, and you will see a..

11:57 pm, June 30, 2019
php
...
using parse_url to extract parts of a url

Category: PHP the parse_url php function will split a url into an array of url fragments $url = "http://kruxor.com/path/?argument=value#anchor"; var_dump(parse_url($url)); parse_url example ..

6:20 am, August 31, 2018
php
...
wordpress register enqueue javascript require jquery

This usually goes in the theme functions file. This will load it after jquery if it requires it. wp_register_script('scriptname', get_template_directory_uri() . '/js/scripts.js', array('jquery'), ..

6:20 am, August 31, 2018
js
...
google map with overlay data

Ever wanted to add a really slightly complex google map to your site? Working Example /* Always set the map height explicitly to define the size of the div * element that con..

6:20 am, August 31, 2018
js
...
slick slider carousel

Nice and simple slider / carousel Slick Example <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css"/> <link rel="s..

6:20 am, August 31, 2018
js
...
validate form data using javascript to check required html elements

for use in a javascript function to submit a form var form = document.getElementById('myForm'); for(var i=0; i < form.elements.length; i++){ if(form.elements[i].value === '' && form.elements[i..

6:20 am, August 31, 2018
js
...
set and check a cookie using js cookie

this library makes setting and checking cookies so easy its amazing! include this script <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.4/js.cookie.m..

6:20 am, August 31, 2018
js
...
jquery clone and append elements

This jquery function clones an element and appends it to another one.  Here is the basic code: $( ".clone-me" ).clone().appendTo( ".append-me" );I also updated this to work with just raw js, so..

6:20 am, August 31, 2018
js
...
show the year with js

just a simple one liner that will show the current year, so no more need for static years in html footers! var d = new Date(); document.getElementById("year").innerHTML = d.getFullYear(); Usage E..

6:20 am, August 31, 2018
html
...
simple dropdown multi level navigation ul li css

updated to work standalone and not effect other list elements on the page

6:20 am, August 31, 2018
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹