10 Google Sheets formulas and Videos with Example Code

Google Sheet Formulas Formula to calculate the average of the values in a given rangeConcatenate two strings and capitalize the first letterCalculate the factorial of a given numberCount the number of occurrences of a given value in a rangeCalculate the distance between two sets of latitude and longitude coordinatesCheck if a given string is a … Read more

Calculate the distance between two sets of latitude and longitude coordinates

The code defines a function called DISTANCE_BETWEEN that calculates the distance between two geographical coordinates on the Earth’s surface using the Haversine formula. Here’s a step-by-step breakdown of the code: Define a constant earthRadius with a value of 6371, representing the Earth’s radius in kilometers. Calculate the difference in latitude (dLat) and longitude (dLon) between … Read more

JavaScript Page element with ID auto global object

In JavaScript, when an HTML element has an id attribute defined, it automatically becomes available as a global variable in the DOM (Document Object Model). This means you can directly access that element using its id as a variable without the need for any explicit lookups or queries. For example, if you have an HTML … Read more

AJAX coding Examples

AJAX examples The provided code handles the submission of a form and makes an asynchronous request to a specified URL using different AJAX techniques (jQuery, Axios, Fetch, and plain JavaScript). It also displays the response received from the server. document.addEventListener(“DOMContentLoaded”, function(event) {     document.querySelector(‘input[name=”sender”]’).addEventListener(‘click’, makeRequest); }); var method = document.getElementById(‘method’); method.addEventListener(‘change’, function() {     var myForm = … Read more

How to Serialize Form data with Vanilla JavaScript

You can use the FormData API in JavaScript. Here’s an example of how you can serialize form data: function serializeFormData(form) { var formData = new FormData(form); var serializedData = {}; for (var [name, value] of formData) { if (serializedData[name]) { if (!Array.isArray(serializedData[name])) { serializedData[name] = [serializedData[name]]; } serializedData[name].push(value); } else { serializedData[name] = value; } … Read more

NodeJS Callback explained with Code Snippet Examples

NodeJS Callback explained with Code Snippet Examples In Node.js, callbacks are a common pattern used to handle asynchronous operations. A callback is a function that is passed as an argument to another function and gets invoked once the asynchronous operation completes or encounters an error. Let’s dive into a detailed explanation with a coding example: … Read more

How to Install NodeJS and set up a text editor

How to Install NodeJS and set up a text editor Congratulations! You have installed Node.js and set up a text editor for Node.js development. You can now create and run Node.js applications using your preferred text editor.

Node JS EventLoop function explained

The event loop is a crucial component of Node.js that allows it to handle asynchronous operations efficiently. Let me explain how it works. In Node.js, the event loop is a mechanism that enables non-blocking I/O operations, such as reading from a file, making network requests, or querying databases, without blocking the execution of other code. … Read more

Store object to localStorage Code Snippet

The code defines two functions, addToStorage() and viewStorage(), that interact with the localStorage object in the browser. The addToStorage() function retrieves the values entered in two form fields using the getElementById() method, and creates an object called myObj with these values as properties. It then logs this object to the console using console.log(). Next, the … Read more

jQuery Code Sample to request Data AJAX

$(document).ready(function() { $.getJSON(‘/users’, function(data) { console.log(data); }); $(‘.btn’).click(function() { var user = $(‘input[name=”user”]’).val(); var pass = $(‘input[name=”pass”]’).val(); $.post(‘/users’, $(‘#myform’).serialize()) .done(function(data) { console.log(data); }); }); }); This code will make a GET request to /users endpoint when the page is loaded, and make a POST request to the same endpoint when the button with class btn … Read more