A basic time difference calculator in google script js

In your Google Sheet, Click “Tools” and then choose “Script Editor“. Put the code given below. Don’t forget to use function in your result column as “=dodiff(cell1,cell2)“ function dodiff(a, b) { if (a) a = fix(a); if (b) b = fix(b); if (Array.isArray(a) && Array.isArray(b)) { if (b[1] > a[1]) m = b[1] - a[1]; else { m = b[1] - a[1] + 60; b[0]--; } if (b[0] >= a[0]) h = b[0] - a[0]; else { h = b[0] - a[0] + 12; } m = m / 60; return (h + m).toPrecision(4); } } function fix(a) { if (a) x = a.toString().replace(" ", '').replace("am", "").replace("pm", "").replace("PM", "").replace("AM", ""); x = x.split(":"); x[0] = parseInt(x[0]); x[1] = parseInt(x[1]); return x; }

October 15, 2019 · 1 min · Harshvardhan Malpani

NodeJS: JavaScript powering the backend.

Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. NodeJS is a JavaScript engine that you can install in your own system. Also, NodeJs makes it possible to use JavaScript in backend development as a backend programming language. (Cool! isn’t it.) You need to know this. Node isn’t a program that you simply launch like Word or Photoshop: you won’t find it pinned to the taskbar or in your list of Apps. To use Node you must type command-line instructions, so you need to be comfortable with (or at least know how to start) a command-line tool like the Windows Command Prompt, PowerShell, or the Git shell. ...

December 30, 2018 · 2 min · Harshvardhan Malpani

Understanding “this” keyword in JavaScript.

‘Hi Everyone! In this article, we are about to discuss **‘this’**keyword in JavaScript. It is a very important part of object-oriented JS programming. Hence it becomes crucial for serious developers to understand **‘this’**keyword. It is also one of the most confused concepts of JavaScript. What is ‘this’? Understanding 'this': To be able to understand what I am about to talk, you should be familiar with the basics of JavaScript. e.x – Variables, Objects, Functions, etc… ...

December 15, 2018 · 3 min · Harshvardhan Malpani

How to manage Magento 2 product attribute values options using console

This is an update to my previous script which was used to add custom product attribute values using backend – Add values to product attribute Read the previous^ part to get introduction about how it works. you will have to use browser console (ctrl + shift +j in Google chrome) First of all initialize the array mimim with the final set of values you want to see in backend. The script then automatically removes the extra options first(values which are not in mimim but in present in backend), then it adds the remaining values from mimim (which are in mimim but not at backend) ...

November 22, 2017 · 1 min · Harshvardhan Malpani