Posts

Showing posts from January, 2022

How To Rotate An Array To Left In Javascript | letsbug

    In this article we are going to rotate an array to left . So basically we are going to shift the elements of the array to the left of the array after some index . And we are going to use javascript for this we you can do this is any language. We some different logic and implementations.     Let me explain you what we are going to do here. Suppose we are given an array with these elements       arr = [ 1 , 2 , 3 , 4 , 5 ]     And we have been given to rotate this array by 2 elements that means that you have to shift all the that are after the index 2 to the left of the array. So you arr will look like this      arr = [ 3 , 4 , 5 , 1 , 2 ]     So let's start coding this in javascript      Array Left Rotation code:     "use strict" ;     function rotLeft (a, d) {         let temp = [];         for ( let i = 0 ; i < a .length; i ++ ) {             temp . push ( a [( i + d ) % a .length]);         }         a = temp ;         return a ;     }     let

How to Find Median Of An Unsorted Array In Javascript And Typescript | letsbug

    In this article we are going make a function which will return the median of the an array which will be passed to the function as parameter. And we are using typescript for this. If you don't know what typescript is please learn about it a little bit. But if you don't know let me tell you in short what typescript is? As you all know that we cannot not define types of variable in javascript. To solve this problem and many more we have typescript. It is a superset of javascript which means any javascript file is typescript file be every typescript file in not javascript.     To run typescript file we have to install the typescript from npm. And then we can use it.     Coming back to the topic we have already made article where we find the median but it was for sorted array. So, let's start.     Median in an unsorted Array     Finding median of an unsorted array is same like sorted array but before we find the median here we first have to sort the array. As you see in t

Counting Sort Algorithm In Javascript | letsbug

Image
     Hey in this article we implementing counting sort algorithm . If you are new to Data Structures and Algorithms you might have not heard about it. Because this is not taught in the colleges like they teach other algorithms like the bubble sort .     If you want to see implement more sorting algorithms click here     So we are going to implement this algorithm in javascript . And if you want to go deep into counting sort and how it works from the basic. You can find many tutorials on the web available. But in this article we are just focused on implementing it javascript. so Counting Sort In Javascript. code:     //counting sort algorithm     function countingSort (arr : number []) :number [] {         let max = Math . max ( ... arr );         let output : number [] = [];         let count : number [] = [];         for ( let i = 0 ; i <= max ; i ++ ) {             count . push ( 0 );         }         for ( let i = 0 ; i < arr . length ; i ++ ) {      

How To Print StairCase Pattern In Javascript | letsbug

Image
      Hi, in this article we are printing staircase pattern in javascript . It will help you understand loops and how you can use then in different ways. Understanding loops and how they work is very important.      Creating Staircase Pattern In Javascript     In the Below function we have first created a function staircase which takes n : number of rows of the staircase as parameter to it. Then the function print the staircase with n rows . In the function we have one outer loop and two inner loops.  code: function staircase (n){     for ( let   i = 0 ; i < n ; i ++ ){         let str = ''         let str1 = ''         for ( let j = 0 ; j < n - i - 1 ; j ++ ){             str += " "         }         for ( let k = 0 ; k <= i ; k ++ ){             str += "#"         }         console . log ( str + str1 )       } } staircase ( 5 ) Output:            #           ##      ###   #### ##### staircase when n is 15 T

How To Create Glass Effect In HTML And CSS | Glassmorphism | letsbug

Image
      Today in this article we are trying something that we have not done in a while that is we are creating a glass like effect in html and css or creating a card in css with glassmorphism. This is going to be a very simple project but we can use this effect in our many different project as per our needs.      So to get started we just need a code editor and a browser to view it and nothing more. But you should know a little bit of HTML and CSS to get started. So here are the steps. Glassmorphism Preview Step one :    Setup a HTML document <!DOCTYPE html> <html lang= "en" > <head>     <meta charset= "UTF-8" >     <meta http-equiv= "X-UA-Compatible" content= "IE=edge" >     <meta name= "viewport" content= "width=device-width, initial-scale=1.0" >     <title> Glass Effect </title> </head> <body>     </body> </html> Step Two : Add HTML elements

How To Preview User selected Image In Javascript And HTML | letsbug

Image
    Hi everyone in this article we are going to see how we can implement the preview image feature in our simple web application using simple javascript .     Before we start make sure you are good at javascript and html in general. This is not a html or css tutorial so we will not focus on that. Our focus is to just implement preview feature in javascript so that you can you it in your project however you like.     So let's get started by  Main index.html <! DOCTYPE html> < html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >     < title > Input image previewer </ title > </ head > < body >     < input type = "file" id = "input" />     < div class = "preview" >

How to convert a HTML table data into CSV file in Javascript | HTML data in Excel | letsbug

Image
      Hello, in this article we are doing a little project. We are doing this using HTML, CSS and Javascript so this is a web project. In this project we are going to see many things some of them are  Creating a dynamic data table in HTML using javascript Creating a beautiful looking table in HTML using css Converting a HTML table into a CSV file And adding a click animation on a button Output main table and button     So let's get started.  How to Create Dynamic HTML Table     To create a dynamic HTML table is very simple. Use javascript to this. You can grab the reference to the table using query selectors and then you can loop through the data which you wanted to add in the table and add them by create new tr and td in the table.     like this code below: //sample data const sample_Data = [{         "Sr. No" : "1" ,         "Name" : "Aniket" ,         "Roll No" : "1"     },     {         "Sr. No" : &q

Program To Print Diamond Pattern | C Programming | letsbug

Image
         Hi everyone in this article we are writing a  C Program to print a diamond pattern . In this program will take input number to as the rows of the pattern that we have to print so that the diamond can be large as you want want and small as you want it to be.     So now let's start the program.     code: #include <stdio.h> #include <conio.h> int main (){     int n , c , k , space = 1 ;     printf ( "Enter number of rows \n " );     scanf ( " %d " , & n );     space = n - 1 ;     for ( k = 1 ; k <= n ; k ++){         for ( c = 1 ; c <= space ; c ++)             printf ( " " );         space --;         for ( c = 1 ; c <= 2 * k - 1 ; c ++)             printf ( "*" );         printf ( " \n " );     }     space = 1 ;     for ( k = 1 ; k <= n - 1 ; k ++){         for ( c = 1 ; c <= space ; c ++)             printf ( " " );         space ++;         for ( c = 1 ; c <

Program To Add Two Complex Numbers | In C Programming | letsubug

Image
       Hi everyone in this article we are writing a C Program to add two complex numbers . Before we start make sure that you are familiar with complex numbers and how the arithmetic operations work on the complex numbers.     So now let's start the program.     code: #include <stdio.h> #include <conio.h> struct complex {     int real , img ; }; int main (){     struct complex a , b , c ;     printf ( "Enter a and b where a + ib is the first complex number. \n " );     printf ( "a = " );     scanf ( " %d " , & a . real );     printf ( "b = " );     scanf ( " %d " , & a . img );     printf ( "Enter c and d where c + id is the second complex number. \n " );     printf ( "c = " );     scanf ( " %d " , & b . real );     printf ( "d = " );     scanf ( " %d " , & b . img );     c . real = a . real + b . real ;     c . img = a . img + b . img ;     if

Money and Credit NCERT Economics Lesson 3 Question & Answers

   Money and Credit     i. In situations with high risks, credit might create further problems for the borrower.     Answer:          In situations with high risks, credit might create further problems for the borrower because: The borrower has to pay fixed interest on the money borrowed. The return on investment may or may not come due to uncertainty in business or farming. If the borrower fails to pay to borrowed money to the lender, then he might face a legal case in the court of law which will create additional problem for him. High risk is associated with high rate of interest.  Payment of high rate of interest will create problem for borrower if returns from his or business are not adequate.  ii. How does money solve the problem of double coincidence of wants? Explain with and example of your own.     Answer:          A person holding money can easily exchange it for any commodity or service that he or she might want. Thus everyone prefers to receive payments in money and then ex

Categories

Big Data Analytics Binary Search Binary Search Tree Binary To Decimal binary tree Breadth First Search Bubble sort C Programming c++ Chemical Reaction and equation class 10 class 10th Class 9 Climate Complex Numbers computer network counting sort CSS Cyber Offenses Cyber Security Cyberstalking Data Science Data Structures Decimal To Binary Development diamond pattern Digital Marketing dust of snow Economics Economics Lesson 4 Email Validation English fire and ice Food Security in India Footprints Without feet Forest And Wildlife Resources game Geography Geography lesson 6 glassmorphism Glossary Graph HackerRank Solution hindi HTML image previewer India-Size And Location Insertion Sort Internet Network Status Interview Questions Introduction to cyber crime and cyber security IT javascript tricks json to CSV converter lesson 2 lesson 1 lesson 2 Lesson 3 Lesson 6 lesson 7 Life lines of National Economy life processes Linear Search Linked List lowest common ancestor Machine Learning MCQs median in array Merge sort min and max of two numbers Moment Money and Credit My Childhood Natural Vegetation and Wildlife NCERT Network connectivity devices Network Models Network Security No Men Are foreign Node.js operator overloading P5.js PHP Physical features of India Population Prime Numbers python Quick sort R language Rain on the roof Regular Expression Resources and development reversing array saakhi science Searching Algorithm Selection sort Social Media Marketing social science Software Engineering Software Testing Sorting Algorithm Stacks staircase pattern System Concepts Text Recognition The last Leaf time converter Time Passed From A Date Todo List App Tree Trending Technologies Understanding Economic Development username and password video player Visualization water resources Wired And Wireless LAN साखी
Show more

Popular Posts

Big Data MCQs(multiple choice questions) with answers - letsbug

Digital Marketing MCQ(Multiple Choice Questions) with Answers | part 1 | letsbug

Software Engineering MCQs questions with answers - letsbug