How To Enable Or Disable Console.log For Debugging

So you are working on your Javascript project and you want to know how to enable or disable console.log messages? Then read on to learn how you can do it quite easily.

Whenever you are working with Javascript, be it on the front-end side with vanilla Javascript or frameworks like React, Vuejs etc. Or on the backend with Node JS, Express JS etc for your servers, you want a way to debug the code. Right?

One of the easiest way we try to debug our code is by using simple print statements. So on the Javascript end, this usually boils down to using console.log( ) messages.

But here is the thing. When you use a programming language that will be compiled – such as C, C++ or Java, we can use compiler flags to enable or disable debug messages.

However, for an interpreted language like Javascript, we dont have a built in method for how to Enable or Disable console.log( ) messages.

So what do we do in that case? Well, if we don’t have a built-in method to enable or disable Javascript console.log( ), then we need to create one!

And that is what we are going to do here. We will be writing a simple Javascript module that we can use to enable or disable Javascript’s console.log( ) messages.

So how do we design this piece of code?

Here is what we are going to do. Instead of using console.log( ) to print our debug messages, we will use our own custom function called debugLog( ). But within this debugLog( ) function, we will have a simple Debug Enable (or) Disable flag.

Now when this flag is set, we will call the console.log( ) in turn and if not set, we will skip printing the log messages. It is as simple as that!

Sounds good? Great! So here is the piece of code that does just that!

How to Enable or Disable console.log
How to Enable or Disable console.log using a switch?

Create a file called “utils.js” and add the following piece of code into it:

DEBUG = true;

function debugLog(msg) {
    if (DEBUG) {

//For express.js, we need to export this module
module.exports = debugLog;

So that is it! From now on, call debugLog( ) instead of console.log( ) to write your debug message. An example piece of such a debug message is shown below:

debugLog("[app] Connect to mongoDB...");

So whenever you want to switch on the debug logging, set the flag as below:

DEBUG = true;

But the moment you want to turn these debug messages OFF, just set it to false:

DEBUG = false;

And that is all there is to it! This is how you can enable or disable console.log( ) messages for debugging!


HTML Meter Tag Explained

HTML Meter Tag is a new type of HTML tag introduced in the HTML 5 specification. So chances are, you are not so familiar with it. Right? But do not worry, as we will start exploring everything there is to the HTML meter tag in this article. So you will soon be able to start using it in your websites and web apps.

Sounds good? Great! Then let us get started!

What Is An HTML Meter Tag?

So consider this situation. You are creating a dashboard in your web app that, among many other things, also shows the storage space left in your hard disk. Now how will you go about designing it?

So the chances are, you might create a custom HTML element that is styled using its CSS properties to display the storage space graphically. But even if it seems a valid solution, problem is you need to keep creating such custom HTML elements frequently. And if you are designing a web app having a dashboard showing multiple data, these custom elements will only increase. Right?

HTML5 Meter tag explained with example
HTML5 Meter tag explained

So then what is an easier solution for this problem than that? Well for one, would it not be easier if we had a built in HTML element to display such measurements? With the growing number of web apps with dashboards, having such a prebuilt HTML element makes sense, right?

Well, that is precisely what the HTML5 specification guys decided to do! And that is how the HTML Meter tag came into picture!

So What Does The Meter Tag Do?

The idea was to create an HTML element that can be used to display any measured values within it. So that is what a Meter tag does!

A Meter tag can be used to display a measured value within a given range of values.

Sounds good? Great! Then let us move on to take a look at an example piece of code that uses the Meter tag. Shall we?

HTML Meter Tag Example

So for this example, let us assume that we want to display the size of a cloud storage space. For brevity, let us say we want to display the size of our mail box which is currently at 66% full. Alright?

So how do we go about using the Meter tag to display this value? And how will the displayed result look like?

To answer these questions, let us start writing our code as shown below:

<!DOCTYLE html>

    <label for="disk">Disk Usage: </label>
    <meter id="disk" value="0.7">70%</meter>

Now, if you copy the above piece of coded into a new file and save it as meter.html, what do you see?

Go ahead and try it out! I want you to do it yourself so that you become familiar with how to use the HTML meter tags.

Did you try it? If you did, you should see that the result looks something like this:



So that is it! That is how the Meter tag works! You just feed the right value into the “value” property of the Meter tag and it will display the meter gauge accordingly. Go ahead and test it out with few more different values and see how the gauge changes yourself.

Finally, if you have any questions or suggestions, let me know in the comment below! So until next time, take care!


Error: Uncaught PermissionDenied: network access to “”, run again with the –allow-net flag

Did you try to run a Deno web server code but came across an error that read: “error: Uncaught PermissionDenied: network access to “”, run again with the –allow-net flag” ?

If yes, then do not worry. Because you are not alone? Even I got excited to run a Deno example web server code but encountered the same error message.

So what is the solution here? How do we go about fixing this?

Well luckily, a solution to this problem is quite easy. Because here is what is happening!

Error: Uncaught PermissionDenied: network access to "", run again with the --allow-net flag

Error: Uncaught PermissionDenied: network access to “” – How To Fix It?

So here is the thing. Deno has security features built into it. So when you try to run a piece of Deno code that uses network, it needs to be run with network permission. Otherwise, you get the above error message!

That is all that is happening here. So we tried to run an example Deno web server application that looked like this:

Deno Server Demo Code

So as you can see from the above Deno code, we are making use of a server module called serve. But this sever code is not on our local computer. So we have imported it from a github repository:


But after downloading it, when we tried to run the code using the command:

deno run server.ts

this is what is happening:

It triggered the serve module to run at port 8000.

However, there is a problem here. So as you see, we have just run the server.ts file as is. That is, we did not issue any explicit permission attached to it. So what happens in that case is that the Deno code tried to run without any extra permissions.

But by default, Deno code does not have permission to access network stuff. So, it just threw the above error!


So what is the solution then? Well, we just need to give network access to this program and it should start working! Right? So what is the command to do that? Here it is:

deno run --allow-net server.ts

So we just attached extra permission before running this Deno code. This will allow our program to use the port 8000 for accessing the server from a browser.

So when we run the above command, we get the output:


And when we access the above url, we can see that the server has rendered the text ‘Hello World’ to the browser.

So that is it! That is all we had to do to fix this Deno network program. Hope it was clear and easy for you!

If you still have any questions, do let me know in the comment section below!

Happy Coding!

Want To Learn Typescript? Take a look at this article!


pytesseract.pytesseract.tesseractnotfounderror: tesseract is not installed or it’s not in your path

In this article, we see how to fix the error : “pytesseract.pytesseract.tesseractnotfounderror: tesseract is not installed or it’s not in your path“.

So are you trying to use the Tesseract tool to do OCR using Python? But some how end up with this error? If yes, then this article will help you in fixing this error.

But before I explain you on how to fix it, here is what we will do. Let me explain you about what is happening here in the first place. Alright? Because if you know what is happening, you will be able to fix similar errors in future as well.

It is not just sufficient to know how to fix a problem. But to know why it happened in the first place. Right? So we will do just that.

What Does The Error Mean?

So let us take a look at the error once again, shall we? Here is what the error looks like:

pytesseract.pytesseract.tesseractnotfounderror How To Fix It?
pytesseract.pytesseract.tesseractnotfounderror How To Fix It?
pytesseract.pytesseract.tesseractnotfounderror: tesseract is not installed or it's not in your path

Does that error message makes any sense to you? No? Actually it does. But only if you know more about how Python’s PyTesseract library.

You see, PyTesseract library is a Python wrapper that makes use of the Tessseract application installed on your computer. So for the PyTesseract library to work, it needs to hook in to the Tesseract app first. But to do that, it needs to know where to find it. Right?

So how does the PyTesseract library know where to find it? Well that is where the OS PATH variables come into picture.

The Python library looks for an OS PATH variable called tesseract. So it is in this variable does it expect to find the path to the Tesseract app.

But when the library cannot find this PATH variable, or the Tesseract app, it will throw the error:

pytesseract.pytesseract.tesseractnotfounderror: tesseract is not installed or it's not in your path

So now that you know the root cause, what is the solution?

How To Fix pytesseract.pytesseract.tesseractnotfounderror?

To fix this problem, you have to follow these few simple steps:

  1. Make sure that Tesseract application is installed.
  2. Make sure that the OS PATH variable tesseract is set to point to the above application file.
    • So if you are on Windows, the tesseract PATH variable will have a value something like this: C:\Program Files (x86)\Tesseract-OCR\tesseract.exe. To find this out, type the below command:
      • echo $tesseract
    • But if you are on Mac or Linux (eg: Ubuntu), it will look like this: /usr/local/bin/tesseract. To find this out, type the below command:
      • echo $tesseract

So that is it! That is how you fix the tesseractnotfounderror error on your Python program.

Hope this helps. Do let me know if you have any questions and I will be happy to answer. See you in the next article. Cheers!

Do You Know The Difference Between Expression Vs Statement In Python?


A ________ value in a loop can be either a positive or a negative number.

So this is a programming quiz question where we need to find what value in a loop can be either a positive or a negative number.

The quiz question goes like this:

A __ value in a loop can be either a positive or a negative number?

To answer this question, we need to think a little bit about how a programming loop works.

A ________ value in a loop can be either a positive or a negative number.

Loop Example

So to do that, let us take an example of a for loop. Now, the syntax of a for loop looks something like this:

for (i=0; i < 10; i++) {
  //do something

So if we look at the above for loop, we can see that it has one variable i. But it is being used in 3 different places, right?

But why?

So for a for loop to execute, we need to have 3 things to it. First, we need an initial value from which the loop begins. In this case, it is done by the code: i = 0;

Next, we need to set a condition. So as long as this condition is true, we will loop. So in this case, we have it set as i < 10. Which means that this loop will run as long as the value of i is less than 10.

But the final part of the for loop is where we change the value of the variable i. So we have it set to i++. But what does it mean?

It means that we want the loop the increase the value of i after every loop is run.

So in all, we this is what we are asking the code to do. We want you to run for as long as the value of i is less than 10. And we start the loop with an initial value of i=0 and let it run until it becomes equal to 10. But as soon as i reaches 10, we want the loop to end!

So if we look at the for loop, it is something like this:

We want it to run as long as a condition is true. And that condition here is set as i to be less than 10. So as long as this condition is met, this code will loop.


So this begs us the question then. What are these type of values called? They are called “step” values.

So to answer our question:

A step value in a loop can be either a positive or a negative number?

Got it?!

Want to learn about Typescript? Check this out!


Add A Variable To URL Of Ajax – How To Guide

So you as a web developer want to have your user be able to add a variable to the URL of his post. But you do not know how to do that? Well do not worry. Because in this tutorial, we will teach you how to do just that!

Now this article is going to get a bit more technical. So I want you guys to be with me all the way through the article, alright? Great! Then it is about time for us to start. Let us go!

Add a variable to URL of Ajax – The Problem

So what is the problem we are looking at over here? Well, it is actually quite simple. We want to be able to add a variable value to the url parameter of the Ajax call.

Add a variable to URL of Ajax
Add a variable to URL of Ajax

So we are talking about a piece of code that looks something like this:

let var myQuery = "What Is My IP?";
$.ajax({url: "" + myQuery, method: 'POST', contentType: false,      cache: false, processData: false,
success: function(result){

So, as you can see from the above code, we are trying to pass in the search query “What Is My IP?” by trying to Add a variable to URL.

And in this case, we have our query stored in a Javascript variable myQuery. So by adding this variable to our Ajax url parameter, we should be able to issue a POST request to Google.

But this is all well and good, but what is the use of this? Why are we even using Ajax call for doing this in the first place? Since we could have just used simple Javascript for a URL query, right?

So to answer this question, we need to know what an Ajax call does.

So we can use simple Javascript code to make an url call. But the problem with that is, the call will be blocking. So our Javascript code will not continue to run until we get back a response from the server.

But on the other hand, using Ajax ensures us that we can make asynchronous requests for the web query. So thereby, our remaining Javascript code will continue to run while we are waiting for the ajax url code’s response.

And by using a Javascript variable like “myQuery” above, we can allow users to add a variable to url to our Jquery ajax request.


So there you have it. It is quite simple to add in a variable to Ajax calls. And I hope that this article helped you learning how to do it.

But if have any more queries about it, do let me know in the comments below. Because I will be more than happy to help you out!

Want to learn about Typescript? Take a look at this article

So with that, I will end this article. See you guys until next time. Cheers!


Typescript Type Conversion

In this article, we will learn how to do type conversion in Typescript. So are you working on Typescript and now want to convert a value from string to number? Or want to convert a number to string in Typescript? Well, then read through this article to learn how to do that!

So here is the thing. You have a Typescript value stored in a variable and you want to use that. But the thing is that, you can not use it as is. Why? Because this number is stored as a string type. But you want to use it as a number. So how can we do that?

Typescript Type Conversion
Typescript Programming Language Logo

That is when the Typescript type conversion comes to your rescue! Using the Typescript type conversion, you can turn that variable’s value from a string to a number!

Sounds great! Right? But then how do we do that in our code? To learn that, take a look at the example code given below:

Example Of Type Conversion from a String to Number

let myStringOfNum: string = "10";
let myNumber: number = Number(myStringOfNum);
console.log(typeof myStringOfNum);
console.log(typeof myNumber);

So if you look at the above code, we have a variable called myStringOfNum that holds a string that reads “10”. But we want that string to be used as a number. So what do we do for that? We use Type Conversions!

So in Line 2, we declared another variable called myNumber. But this time, this variable is of type number. What we do next is that we will take the value of the vairable myStringOfNum and convert its type to Number. We do that by using the typecast Number(). The resulting value is then assigned to our variable myNumber.

So in that case, our console output will look like this:


Example Of Type Conversion from a Number to String

In a similar way, we can convert a number to string in Typescript. So when we take a look at this code:

let myNumber: number = 10
let myString: string = String(number)
console.log(typeof myNumber);
console.log(typeof myString);

What do you think how to output will look like? I think your guess will be:



So in summary, we can convert a number to string or a string to number using Typescript’s Type conversion feature. I guess it could not have been any more simpler than this. What do you guys think? It is, Right?

Learn this difference between an expression and a statement here


Math Worksheets Printable For Free

Here is a list of Math Worksheets in Printable format. Since they are free, you can download these maths worksheets and print it out. So now you can use them to test your kids on their math skills.

But before we show you these printable math worksheets, let me tell you how to make use of it. Sound good? Great! Then let us start on that!

Who can use these printable Math Worksheets?

So before we look into the worksheets, we need to first know who can make use of it. After all, looking at a math worksheet that is not meant for you is a time waste. Isn’t it? So we need to first be clear on who can use it.

You see, we are going to give you many of these worksheets for you to download. So, there is no one answer for this question.

Because, each of these worksheets test your math skills at different levels. So then, how will you know which is the one for you?

Well, that is a good question! So that is why we will be giving different set of worksheets for different grade of students.

So in other words, we will give you these math worksheets divided into different groups. Where each group is useful for different student grades.

Wait a second! But what does that mean?

Well it means that we have printable math worksheets for class 2, 3, 4, 5 all the way up to grade 9! Sounds good, then. Right? 😉

Alright then. If that made sense to you. Let us start to look at each of these maths worksheets. Shall we?

Printable Math Worksheet For 2nd Grade

So we will start with a math worksheet that we have made for a 2nd grade student. Here is how it looks like:

Printable math worksheet for 2nd grade
Printable math worksheet for 2nd grade

So here is our first math worksheet for 2nd grade kids. How do you think of it? Did you like it? Well, I know that it is quite simple. But that is part of the reason why it is best math worksheet for 2nd grade kids.

Why this math worksheet for a 2nd grade kid

Because, all they have to do is add two numbers in the given worksheet and enter their answers. Now that is something that a 2nd grade kid can do, right?

So you see, the idea here is to give you a maths worksheet that you can download and hand it over to your kid. But your kid should also find it easy to answer. Because you cant over burden them at the early stages. Right?

So this was our first math worksheet we had for you. You can download then for free and give a printed version of this worksheet to your kid.

In the next set of articles, we will give you some more math worksheets for other grade students. But that is for later date. So if you like this worksheet, do share it with your friends and colleagues.

We want every student out there to be good at math. But to do that, we need to first give them a good basic foundation. So this set of math worksheets are designed to do just that.

By using these worksheets, your students should get comfortable with math. And not see it as something to avoid! So if we are able to reach there, we can say we have hit the right nail!

With this, we end our article here. But do check on our other articles on science that can help your kids in learning better.


Rewrite each expression without absolute value bars

Rewrite each expression without absolute value bars:
a. ∣1 − √2∣ b. ∣π − 3∣ c. ∣x∣/x

So this is a problem we have taken from the book Precalculus Essentials 5th Edition written by Robert F. Blitzer.

Are you not able to find it in the book? Well do not worry! Just go to the Pre-requisites chapter P part of the book and look for problem Check Point 6. It is in page 10 of the book.

So with that said, let us now try to solve this problem. But how do we do that?

Rewrite each expression without absoulte value bars
Rewrite each expression without absoulte value bars

The answer is to break down the problem into smaller parts. To do that, let us re-read the problem statement once again.

Rewrite each expression without absolute value bars:

So what is it asking us to do? It is asking us to find the value of each of the expressions, right? But there is a condition to be met. It wants us to find the value without using the absolute value bars.

So what does it mean?

It means that we need to get rid of the absolute value represented by the | | symbol. But how do we do that? To know more about it, let us first learn what an absolute value is. Alright?

What is an Absolute value?

When we try to solve any expression, we get an output value, right? But here is the thing. This output value can be either positive or negative. Still not clear? Well then, take a look at this example:

y = x + 3

Now, in the above expression, the value of y can be both positive or negative, right?

So if the value of x is 6, we get y = 9. But on the other hand, if x = -4, we get y = -1.

So as you can see from above, the final value of y can be positive or negative. It depends on the value of x.

Are you clear up to this point? Great!

So what do we do in case of an absolute value? Well if we want to find the absolute value of y, we will drop the sign symbol. So in that case, when x=-4, y=1!

So we represent absolute value of this equation using the formula:

y = | x + 3 |

So whenever you see the symbol | |, it means we are taking the absolute value of it where we drop the -ve sign.

In other words, you can also say that an absolute value is always +ve.

So now that we have learnt what an absolute value is, let us answer our actual question.

Rewrite each expression without absolute value bars

So let us start solving this question one by one. Let us take a look at the first problem:

a. ∣1 − √2∣

a. ∣1 − √2∣

So let us first break down the problem first. To begin with, we will drop the absolute value bars.

So the problem simply becomes: 1 − √2

But we know that the value of √2 = 1.4142

So what will be the value for (1 – 1.4142) ?

Yes, 1 – 1.4142 = -0.4142

So as you can see, we have a negative valued result. So the final answer will be:

Answer: 1 − √2 = -0.4142

In similar ways, we can now rewrite each expression without absolute value bars as shown below:

b. Rewrite each expression for ∣π − 3∣

So the expression here is

π − 3∣

which without absolute value becomes equal to:

π − 3

Now we know the value of π = 3.1415

So the resulting answer will be:

Answer: 3.1415 – 3 = 0.1415

c. ∣x∣/x

So now coming to the final question, the answer is straight forward:

Ansswer: x/x = 1

Looking to solve an Engineering problem? Check this out!


BMI Calculator For Men

In this article, we will take a look at the BMI calculator for men. So, using this calculator, you will be able to check your Body Mass Index. But it wont stop just at that. Because this BMI tool will also tell you if you are over weight, under weight or at the normal weight.

BMI Calculator for Men

BMI Calculator For Men
BMI Calculator For Men Online

Calculate your BMI by entering your body weight and body height in the fields given below:

Enter Your Weight (in Kg):
Enter Your Height(in cm):

Your BMI Value Is:

Check what your resulting BMI value means over here.

So how is knowing your Body Mass Index value going to help you? Well, it is quite simple. You see, the BMI tool gives out BMI value for your body. So using this BMI value, you can check if you are at the right body weight for your age and height.

Now if you are in the normal BMI range, then all is well and good. But in case you are not, then it will tell you if you are under the normal body weight or over the normal weight.

So knowing if you are under weight or over weight will help you in figuring out what you should eat.

Wait what? How is that?

Yes, you read that right. Because if your BMI is not in the normal weight range, then you need to change your eating habits. Or in other words, you need to change your diet.

But why? Well, it is because if you are under weight, you will need to eat more food that is rich in calories. But on the other hand if you are under weight, you need to eat food with fewer calories.

That makes sense right? So that is why we will use the BMI Calculator for Men to find out what you should be doing about what you eat.

But before we go ahead using the BMI calculator for men, we should first know what is it, right? So we will start from there!

What Is Body Mass Index (BMI)?

Body Mass Index or BMI is a value that we get by dividing our body weight by the square of our body height. So in other words, we can calculate BMI using the formula:

BMI = (Body Weight in kg) / (Body Height in meters)²

So what doe this equation of BMI index mean? What is it doing logically?

What does a BMI calculate?

So as you can see above, we are using two values of our body to calculate our BMI. We take the body weight in Kilograms and divide it by the square of our body height given in meters.

So what does that mean? What do you think we are calculating here?

Logical Explanation Of BMI Calculator For Men

Well, in simple terms, we are just trying to see how much of a body mass we have per square meter, isn’t it. So in a way, we are trying to calculate the mass occupied by our body in a given square meter area!

It is as simple as that!

How Is BMI Calculator For Men Useful?

So now that we know how to calculate the BMI for men, we need to ask the next question. How is BMI going to be useful for us?

So here is thing. If you are a healthy man, you will be physically fit. Which in turn means that your physical appearance will also be good, right. So what tells us that? Well, for the most cases it is going to be your height and weight.

Makes sense, right?

Well think about it. If you are physically active, you will be burning most of the calories that you eat in any given day. Right? Which means that your body will have less body fat stored and well built muscles as you do more activities. Right?

So in that case, there will be a specific body weight for your body height which will be considered ideal. Correct? So that is exactly what BMI for men is giving us!

Bod Mass Index Range

BMI Range

Now that we what a BMI is,it is time to learn about the BMI range. So we calculated the BMI value. That is all well and good. But what does the value even mean? How will we know if we are over weight, healthy weigh tor under weight?

That is exactly when the BMI range comes into picture. The easiest way for us to understand it is to take a look at it below:

BMI Range Table

BMI RangeWeight Status Category
Below 18.5Underweight
18.5 to 24.9Healthy Weight
25 to 29.9Overweight
30 or aboveObese

So as you can see from the above BMI Range table, we are underweight if our BMI turns out to be below 18.5

But if our BMI calculator outputs a value between 18.5 to 24.9, then we are at our healthy weight!

On the other hand, if our BMI is between 25 to 29.9, we are considered overweight.

But if our BMI is more than 30, we are considered as obese.

Pretty handy way to find it out then. Yeah? 😉

So what ever value we get, at the end of the day, we will get to know if we are healthy or not. Now that is all that really matters, eh?


So there you have it. This is why you need to use the BMI calculator for men app given above to check your BMI. But if you still have any thing to ask, do let us know in the comment section below. We will be more than happy to answer you!

So with that said, we will end this article over here. Hope you were able to check your BMI value and learnt to take the right action from now on.

If you want to stay healthy, make sure you keep your body weight under control. If you need some more ideas about it, do read this blog for more. Hope you have a great healthy life ahead! Cheers guys!

Want to keep your Blood Pressure (BP) level in check? Then check this Best Pulse Oximeter buying guide.