Found 10677 Articles for Web Development

Finding two numbers that produce equal to the sum of rest in JavaScript

AmitDiwan
Updated on 22-Feb-2021 10:22:40

244 Views

Suppose following is the problem:We have a sequence of numbers starting from 1 and upto any arbitrary number, let's call it num. We have to pick two such numbers from the sequence (let's call them m and n), such that:sum(1 to num) - (m + n) = m * nAnd finally, we should return an array of groups of all such numbers.For example −If the input is −const num = 10;Then the output should be −const output = [    [7, 6] ];because sum(1 to 10) = 55and, 55 - (6 + 7) = 6 * 7 = 42ExampleThe code ... Read More

How to set cookie value with AJAX request in JavaScript?

AmitDiwan
Updated on 22-Feb-2021 09:27:40

3K+ Views

We are required to set cookies with AJAX requests or in such a way that any AJAX request sends those cookies to the server.One thing to note here is that every AJAX request made to any remote server automatically sends all our cookies to that very server without us having to do anything. Therefore, with this thing clear, we just have to set a specific key to our document object using JavaScript and whenever we make a network call, that cookie will automatically be sent to the server which we are making the call to.The code for setting the cookie ... Read More

Why doesn’t Postman get a “No 'Access-ControlAllow-Origin' header is present on the requested resource” error in JavaScript

AmitDiwan
Updated on 22-Feb-2021 09:26:23

680 Views

Problem:When we try to make network request to a remote server whose origin is different to our current url (from which we are making the request), we most likely get a CORS error due to different origin problem in the web, whereas while using a tool like Postman, we can successfully avoid this CORS error.We are required to explain the difference in behaviour of response when requested through web and when requested through an extension like postman.Explanation:When we make a network request to a different domain than our page is on using a web browser, it blocks that request and ... Read More

Preview an image before it is uploaded in JavaScript

Aayush Mohan Sinha
Updated on 04-Aug-2023 10:26:33

7K+ Views

The ability to preview an image before it is uploaded holds significant value in the realm of web development, allowing users to have a glimpse of their selected image and make necessary adjustments prior to submission. Employing JavaScript, a versatile programming language, developers can harness the power of client-side processing to implement this functionality seamlessly. In this article, we will embark on an exploration of how to preview an image before it is uploaded using JavaScript, unveiling a step-by-step approach and leveraging seldom-utilized techniques to accomplish this task. By delving into the intricate details of this process, developers will gain ... Read More

How to take screenshot of a div with JavaScript

AmitDiwan
Updated on 22-Feb-2021 14:01:44

2K+ Views

We are required to capture (convert into image) part(s) of our markup that lays out our website and save that captured image or do something with it. So, we are required to devise a way using which we can achieve this described behaviour.As our problem includes capturing any markup element and not just canvas, it’s a bit complex and especially if we plan to do it from scratch. Therefore, for our ease we will use a third party library, htmltocanvas that does exactly what the name suggests, converting the desired markup to canvas, after which we can simply download the canvas ... Read More

How to read an external JSON file in JavaScript

AmitDiwan
Updated on 22-Feb-2021 09:17:50

5K+ Views

Suppose we have a JSON file config.json that contains the following data −{    "secret": "sfsaad7898fdsfsdf^*($%^*$",    "connectionString":    "mongodb+srv://username:password@cluster0.laaif.mongodb.net/events?retryWrites=tr    ue&w=majority",    "localConnectionString":    "mongodb+srv://username:password@cluster0.laaif.mongodb.net/eventsLocal?retryWrit    es=true&w=majority",    "frontendClient": "https://helloworld.com",    "localFrontendClient": "http://localhost:3000" }And in the same directory (folder), we have a JavaScript file index.js.Our task is to access the content of the json file through the JavaScript file.Method 1: Using require module (NodeJS environment only)We can use the require module to access the json file if we are running our JavaScript file in NodeJS environment.ExampleThe code for this will be −const configData = require('./config.json'); console.log(typeof configData); console.log(configData);Method 2: ... Read More

Navigating your dashboard in Canva

Zahwah Jameel
Updated on 19-Feb-2021 11:05:35

421 Views

Canva is a free graphic designing tool that allows you to create professional designs without any prior skills.Before you dive in and start designing with Canva, you should know about the dashboard of your Canva account so that you can use the features.This is how your account’s dashboard on Canva will look like.Here a few things you can do through your account’s dashboard.Creating a designYou can go to the design tab through various ways from your dashboard.You can click on the ‘create a design’ option present in the top-right corner.You can scroll down and select the suitable template to start ... Read More

How to design a logo using Canva?

Zahwah Jameel
Updated on 19-Feb-2021 11:01:58

405 Views

If you are looking to create a logo that represents the face of your company but you don’t have the skills, you can always use Canva. Canva helps you create professional designs in a few minutes. Besides, Canva is free and open to everyone.To create a logo using Canva, follow these four steps.Click ‘create a design’Go to the homepage of Canva and press the ‘create a design’ button. You will find it on the topmost right corner of your dashboard.From the drop−down list of options, select the logo.You will be automatically redirected to the design tab.Select a suitable templateThis is ... Read More

How to design a creative poster using Canva?

Zahwah Jameel
Updated on 19-Feb-2021 10:56:44

3K+ Views

To design a professional and engaging poster using Canva, follow these steps.Click ‘create a design’Go to your account dashboard press create a design button on the topmost right corner of the webpage. You will see a drop−down menu of various options appearing.We will select a poster for our design. There are two options when it comes to creating posters, portrait and landscape types. The default poster option is of portrait type.For our design, we will design a poster with the default dimensionsSelect a suitable templateAfter selecting the type of design, the design tab opens.This is how the design tab looks. ... Read More

How to create a new Canva account?

Zahwah Jameel
Updated on 19-Feb-2021 10:50:11

3K+ Views

When it comes to creating engaging and professional design in a few minutes, Canva is the best graphic designing tool. Also, it is free and open for everyone.To start creating your digital designs on Canva, you need to signup for a Canva account. Having a Canva account is important because −It keeps all your designs saved. You can access them from your account, edit, download them to your local file, or delete them.You can arrange your designs in folders.You can share your designs with others and allow others to share their designs with you.You can create a design team.If you ... Read More

Advertisements