Home » 2021 » November

Checking for Inequality in Python: ‘!=’ vs ‘is not’ [Examples]

Python Not Equal

Should you use the != operator or the ‘is not’ statement when comparing values in Python? Read on to find out! The != Comparison Operator The != operator can be used to compare two variables or statements’ return values. If they are not equal, the statement will return TRUE. Python is forgiving when it comes to comparing variables of different types. So if the type of the variables being compared is different, but the value is the same, it will return TRUE (rather than throwing an error) as they are not equal in both type and value. myNumber … Read more

Home » 2021 » November

How to Use the PHP *strstr()* Function to Search a String

This tutorial will show you how to use the PHP strstr() function to search and return a portion of a string, with examples. What is the strstr() Function For? The strstr() function searches a string and returns the matching portion of the string and everything that follows or precedes it. If the string does not contain a match for the search, a value of false is returned. It’s a hard one to visualize – the examples below will show you precisely what this means. If you’re simply looking to confirm whether … Read more

Categories PHP

Home » 2021 » November

How to Round Numbers (Integer, Decimals) in PHP with the round() Function

This article will show you how to round numbers in PHP with the round() function, including rounding to the nearest integer or a set number of decimal places. Why Round Numbers? There are various reasons you may want to round numbers. You don’t need incredible accuracy for many day-to-day calculations. You probably don’t need to know your height to several thousandths of a centimeter if converting from feet – knowing to the nearest whole centimeter is perhaps enough. If you’re calculating tax, you only need to know … Read more

Categories PHP

Home » 2021 » November

Implementing a Queue Data Structure in JavaScript [Examples]

A queue is a commonly used data structure in programming. Here’s how to implement and use a queue in JavaScript. JavaScript doesn’t include a data structure specifically called a queue – but that doesn’t mean the functionality isn’t there. JavaScript arrays can be used in the same way – it’s just the terminology that’s a bit different. Rather than duplicating array functionality for queues, queue functionality exists in the array functions of JavaScript. What is a Queue Data Structure? A queue is a sequence of items in a specific order. Items can be enqueued (added … Read more

Home » 2021 » November

Rasperry Pi RetroPie Emulation Station Install Walkthrough (Video Games on Pi)

This guide will walk you through the installation and configuration of RetroPie (a Linux distribution with Emulation Station pre-configured) and where to source some legal retro game console ROMS. RetroPie is a ready-to-use Linux OS for your Raspberry Pi, which has everything already configured and ready to emulate NES, SNES, GameBoy, Nintendo 64, Playstation, Sega, and many other game consoles. The installation and configuration steps are super easy.  I’ve documented them below with screenshots and notes.  Once RetroPie is up and running, I’ll install a … Read more

Home » 2021 » November

The Best Way to Declare an Array in JavaScript

There are several ways to declare an array in JavaScript. This article will show you which is the best. What is an Array? An array is a type of variable that holds an ordered list of values. Each value has a position in the array, called the index. The index can be used to access each value in the array. Indexes are integer values, which start counting from 0 (zero) for the first item in the array. The Literal Constructor – Declaring an Array using Square Brackets (The Best … Read more

Home » 2021 » November

Merge Arrays in JavaScript with concat() and push() [Examples]

This tutorial will show you the correct ways to merge two or more arrays in JavaScript with the concat method – and provide a warning about how not to merge arrays. Merging/Joining Arrays in JavaScript with the concat()* Method The concat() method exists with one purpose – to merge arrays. concat() Method Syntax array.concat(ARRAYS) Note that: array is the first array of the arrays to be joined ARRAYS should be a comma-separated list of arrays to be added to the first array They will be joined in the order of appearance concat() returns a new array – … Read more

Home » 2021 » November

How to Add one or More Items to an Array In JavaScript with push()

This tutorial will show you how to add items to a JavaScript array with the push() method – with code examples. You don’t want to have to re-declare an array every time you want to change the values in it – so let’s look at how to add items to existing arrays using the push() method. About JavaScript Arrays and Declaring Arrays I’ve covered the best way to declare Arrays in JavaScript in our article here. JavaScript Array push() Method Syntax A method is a function or procedure attached to an object. Calling that object’s … Read more

Home » 2021 » November

How to Randomize/Shuffle an Array in JavaScript [Examples]

This article will show you a few ways, both easy and complex, to randomize/shuffle an array in JavaScript. The Quick and Dirty Way to Randomize an Array If you aren’t too concerned about the probabilities involved, this code is a quick way to randomize the contents of an array: // Function to return a shuffled copy of a given array function shuffle(array) { var shuffled = […array]; // Make a copy of the array to be shuffled so that the original is not altered by … Read more

Home » 2021 » November

How to Reverse an Array In JavaScript

This short article will show you how to reverse an array in the JavaScript programming language. What is an Array? An array is a type of variable that holds an ordered list of values. Each value has a position in the array, called the index – and can be accessed by using that index. As an array is ordered, the position matters. Values within arrays will be processed by loops and other data structures in order – so being able to reverse that order is beneficial. Reversing an … Read more

Exit mobile version