JS data/time, JavaScript & iPython, and much more
JavaScript is a famous programming language and 97.9% of websites do use this programming language. But JavaScript developers face many problems and today we’ll discuss some of them.
date/time field value out of range in JavaScript
This is a widespread problem in JavaScript and every new JS programmer faces it. To create a date/time value, we need the DateConstructor which can be accessed via the Date Object.
The Code:
let date = new Date(); console.log(date)
The Output:
2022-11-24T08:28:19.558Z
You can create a date/time value by using this code.
JavaScript error: ipython is not defined
You may face this problem while using JupyterLab. You have the latest anaconda package and python but you are still facing this problem!
But by following my steps you can fix this problem quickly. If you’re using this extension then I will recommend you use a version upper than 3.0 and this is the first step.
Steps for using conda
conda install -c conda-forge ipympl # If using JupyterLab 2 conda install nodejs jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter lab build # Later, if updating a previous Lab install: conda install ipympl jupyter lab build
Steps for using Pip
pip install ipympl # If using JupyterLab 2 pip install nodejs jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter labextension install jupyter-matplotlib
JavaScript Date Time Format
Now you know that how you can get the value of data/time. But you don’t know how to format it. Now I’m going to show you that how you can also format the value of date/time.
The Code:
var date_and_time = new Date(); function formatDate(data){ var date = data.getDate(); var month = data.getMonth(); month++; var year = data.getFullYear(); return date + "-" + month + "-" + year; } console.log(formatDate(date_and_time));
Here we first create a Date object then we create a function that will format the object value like three variables will store three different values and in the end, this function will return a string.
Read More: Top 10 Polytechnic Institutes in Bangladesh
After creating this function we can use the function to format the object or the value of date/time.
The Output:
29-11-2022
Data Structures and Algorithms with JavaScript
The main and most important concept of programming is data structures and algorithms. And it’s also the same in JavaScript. Yes, C++, Java, or Python is indeed the best choice for learning data structures and algorithms (DSA). Because in the field of DSA those three languages have a huge community and great support. You will find tons of resources if you go with those three languages.
But, if you want to learn data structures and algorithms with JavaScript, it’s alright. You can do it. You can follow some courses which are available on YouTube or you can follow some paid courses from Udemy or any other sources.
Let me tell you about some resources out there on the internet.
For JavaScript Basic (YouTube Channel Link):
Single Videos Links
- English Videos
- Hindi Videos
- Bangla Videos
YouTube Playlist Links to learn JavaScript
- English Videos Playlist
- Hindi Videos Playlist
- Bangla Videos Playlist
After learning the basic part of JavaScript you can now move on to the intermediate or advanced level. For that I will recommend you to visit a GitHub link. Click here to visit the page. Here you’ll find lots of DSA articles with JavaScript for free.
Read More: How to split up a string in JavaScript using the split function
You can follow a YouTube playlist to learn DSA using JavaScript. This course is great and the teaching method is easy and fun. Tutorial link: JavaScript Algorithms.
And then if you want some paid courses Udemy will be a great place for that. You can follow or purchase some courses like “JavaScript Algorithms and Data Structures Masterclass” or “Data Structures & Algorithms – JavaScript”.
So this is the whole suggestion or path to learning Data Structures and Algorithms with JavaScript.
How to add two numbers using JavaScript
How to add two numbers or integers in JavaScript. I know many of you already know that but still, I just want to add one simple question in this article for absolute beginners.
Finding the sum in JavaScript is easy. Just create two variables and store two values on them then just console.log the sum. Let me show you how to do that.
let a = 7; let b = 1; console.log(a + b);
Conclusion
So this is the whole article and I hope by reading this article you learned a lot. Even if you learn a little I hope it will be helpful in your programming life.
If you want to add something to this article you can tell us that by commenting below in the comment box.