<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Swati Agrawal on Medium]]></title>
        <description><![CDATA[Stories by Swati Agrawal on Medium]]></description>
        <link>https://medium.com/@swtigrwal21?source=rss-752f30e3e50d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OhEXg6KB3-r4_qfRTDNQQw.jpeg</url>
            <title>Stories by Swati Agrawal on Medium</title>
            <link>https://medium.com/@swtigrwal21?source=rss-752f30e3e50d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 23:52:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@swtigrwal21/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Advanced Arrays in JavaScript-Beyond the Basics]]></title>
            <link>https://medium.com/@swtigrwal21/advanced-arrays-in-javascript-beyond-the-basics-b1167016f847?source=rss-752f30e3e50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1167016f847</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-array-methods]]></category>
            <category><![CDATA[advance-array]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Swati Agrawal]]></dc:creator>
            <pubDate>Thu, 26 Feb 2026 07:55:13 GMT</pubDate>
            <atom:updated>2026-02-26T07:55:13.483Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>You</strong> have already understood what arrays are and how to use basic methods. Now it’s time to move to the next level-where arrays become powerful tools for real-world development. In JavaScript we have a powerful built-in methods that allow us to manipulate complex data.These methods often replace traditional loops, resulting is cleaner and shorten the line of code which is more efficient, and more readable.</p><p>In this article, we’ll go beyond basics and explore advanced array methods that professional developers use daily. If you master these, your JavaScript level will immediately improve.</p><p><strong>Why Advanced array methods matter</strong></p><p>· Working with real API data</p><p>· Avoiding unnecessary loops</p><p>· Writing clean and short code</p><p>· Transforming and filtering information according to requirements</p><p><strong>The most important advanced methods are those used for iteration, transformation, and aggregation are:</strong></p><p><strong>1.map ()-It Transforms data</strong></p><p><strong>map()</strong> creates a new array by modifying each element of an array by calling a specific function.</p><pre>const price=[200,700,500]<br>const discountedPrice=price.map((price)=&gt;price-50);<br>console.log(discountedPrice);</pre><p><strong>Output:</strong></p><p>[150,650,450]</p><p><strong>When to use map() and what it is doing:</strong></p><p>· Modifying values and creating new array</p><p>· Transform API data</p><p>· Returns a new array without changing the original array</p><p>· Extract specific properties from array</p><p><strong>2.reduce()-Combine everything into a single value</strong></p><p>Reduce() is one of the most powerful array methods, it iterate over the all array elements and return a single value.</p><p>Syntax:</p><p>array.reduce((accumulator,currentvalue)=&gt;</p><p>{</p><p>return updatedValue;</p><p>},initialValue);</p><pre>const price=[200,700,500];<br>const sum=price.reduce((acc,curr)=&gt;acc+curr,0);<br>console.log(&quot;Sum=&quot;,sum);</pre><p><strong>Output :</strong></p><p>Sum=1400</p><p><strong>When to use reduce() and what it is doing:</strong></p><p>· Calculate total in shopping cart values</p><p>· Group data and return single value</p><p>· Built objects dynamically</p><p>· Total the marks in marksheets</p><p><strong>3.filter()-Filter the specific data</strong></p><p>filter () returns the new array that satisfies the given conditions.</p><pre>const marks=[45,23,38,40,33];<br>const passStudents=marks.filter(element=&gt;element&gt;=35);<br>console.log(&quot;filteredData:&quot;,passStudents);</pre><p><strong>Output :</strong></p><p>filteredData:[45,38,40]</p><p><strong>4.find():</strong>It check all the array elements and returns the first element that satisfied the given condition if no element satisfied the condition, it returns <strong>undefined</strong>.</p><pre>const marks=[45,23,38,40,33];<br>const passStudents=marks.find(element=&gt;element&gt;=35);<br>console.log(passStudents);</pre><p><strong>Output :</strong> 45</p><p><strong>5.forEach()-</strong>It is loop that runs a function for each element of an array .forEach() is good for printing all the elements of array.It does not return new array.</p><pre>const fruits=[&quot;Apple&quot;,&quot;Mango&quot;,&quot;Orange&quot;,&quot;Banana&quot;];<br>fruits.forEach(fruits=&gt;{console.log(fruits)<br>});</pre><p><strong>6.findIndex():</strong>Returns the index of the <em>first</em> element that satisfies a given condition. The search stops as soon as a match is found, if no element satisfied the condition it returns <strong>-1.</strong></p><pre>const marks=[45,23,38,40,33];<br>const passStudents=marks.findIndex(element=&gt;element&gt;=35);<br>console.log(passStudents);</pre><p><strong>Output :</strong></p><p>0</p><p><strong>7.sort():</strong>Sort the elements in ascending/descending order.</p><pre>const numbers=[45,23,38,40,33];<br>numbers.sort((a,b)=&gt;a-b);<br>console.log(numbers);</pre><p><strong>Output:</strong></p><p>[23,33,38,40,45]</p><p><strong>8.flat():</strong>Flatten nested arrays means create a new array with all the nested array.</p><pre>const arr=[1,2,[4,6]];<br>console.log(arr.flat());</pre><p><strong>Output:</strong></p><p>[1,2,4,6]</p><p><strong>9.flatMap():</strong>It combines the both functionality map() and flat() in single method.</p><pre>const strings=[&quot;Java and JavaScript&quot;,&quot;c and c++&quot;];<br>const result=strings.flatMap(ele=&gt;ele.split(&quot;and&quot;));<br>console.log(result);</pre><p><strong>Output:</strong></p><p>[‘Java ‘, ‘ JavaScript’, ‘c ‘, ‘ c++’]</p><p><strong>Real Project Example(mini Scenario)</strong></p><pre>const persons=[<br>{&quot;name&quot; : &quot;Marking&quot;, &quot;age&quot; : 33},<br>{&quot;name&quot; : &quot;Ustevn&quot;, &quot;age&quot; : 68},<br>{&quot;name&quot; : &quot;Mariya&quot;, &quot;age&quot; : 75},<br>{&quot;name&quot; : &quot;Wimbill&quot;, &quot;age&quot; : 46}<br>]<br><br>//Get more senior  citizen<br>const seniors=persons.filter(ele=&gt;ele.age&gt;60);<br>console.log(&quot;SeniorCitizen &quot;,seniors);<br><br>//Total the age<br>const total=persons.reduce((acc,curr)=&gt;acc+curr.age,0);<br>console.log(&quot;Sum of ages=&quot;,total);<br><br>//Get only name of persons<br><br>const names=persons.map((ele)=&gt;ele.name);<br>console.log(&quot;Name=&quot;,names);</pre><p><em>This is how we use advanced array methods.</em></p><p><strong>Final Thoughts</strong></p><p>If you learn these methods your code becomes shorter and clearer. Your logic and written code are looks like a professional level JavaScript code so master this advanced array methods. Most of the interview questions and projects demands the map(),reduce() and filter() so practical them deeply.</p><p><strong>Common Beginner Mistakes:</strong></p><p>· Using map() instead of forEach()</p><p>· Forgetting to return in map()</p><p>· Using sort without comparing functions</p><p>· In reduce() not providing initial value</p><p>· Modifying original array instead of creating copy</p><p><strong>Practice Questions (Beginner to Advanced)</strong></p><p>1.Given a number of arrays, Create a new array where every number is double of given array.</p><p>const numbers=[2,5,9,7];</p><p>2.Given a number array find the sum of all numbers.</p><p>const numbers=[78,82,23]</p><p>3.Given n array find the count how many times each word appears.</p><p>(Hint: use reduce())</p><p>const color=[“red”,”blue”,”red”,”orange”,”blue”,”black”,”red”]</p><p>expected output:</p><p>{red: 3, blue: 2, orange: 1, black: 1}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1167016f847" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Arrays in JavaScript (Complete Beginner Guide)]]></title>
            <link>https://medium.com/@swtigrwal21/arrays-in-javascript-complete-beginner-guide-b3b4713f27e8?source=rss-752f30e3e50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3b4713f27e8</guid>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[array-in-javascript]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Swati Agrawal]]></dc:creator>
            <pubDate>Wed, 18 Feb 2026 11:33:01 GMT</pubDate>
            <atom:updated>2026-02-18T11:33:01.938Z</atom:updated>
            <content:encoded><![CDATA[<p>When we are working with programming languages sometimes, we need to store a multiple values together.</p><p>Storing values in separate variables is not good practice. This is where Array help us.</p><p>In this article, you will learn<strong> Arrays</strong> in JavaScript with simple and beginner friendly way.</p><p><strong>What is an Array in JavaScript?</strong></p><p><strong>Arrays</strong> are one of a data types used in JavaScript to help organize and store data. Arrays enable us to store an <em>ordered</em> collection of data.</p><p>An array is a list-like objects that stores multiple values in a single variable. Each value inside an array is called element, and every element has a position called index that starts from 0.</p><p>Example:</p><pre>let fruits=[&quot;Apple&quot;,&quot;Mango&quot;,&quot;Banana&quot;];</pre><p><strong>Why Do we need arrays?</strong></p><p>If we have a large data, then we make a array of that data array make it easier to manage and process them efficiently.</p><p>We need array to</p><p>· Store multiple values together</p><p>· Reduce repetition of code</p><p>· Arrays can store mixed data types like numbers, strings, objects</p><p>· Easy to loop and process data</p><p><strong>How to create Arrays</strong></p><ol><li>Using Array Literals (most common way)</li></ol><pre>let numbers=[5,8,9,3];</pre><p>2. With the array constructor</p><pre>let numbers=new Array(5,8,9,3);</pre><p>3.Mixed Data Types</p><pre>let data=[&quot;Alisha&quot;,25,false,{fruit:&#39;Apple&#39;}];</pre><p><strong>Accessing Array Elements</strong></p><p>We can access array elements using its index number that starts from 0.</p><pre>let fruits=[&quot;Apple&quot;,&quot;Mango&quot;,&quot;Banana&quot;];<br>console.log(fruits[0]);<br>console.log(fruits[1]);</pre><p><strong>Modifying Array Elements</strong></p><p>Array elements can be modified by assigning a new value to their corresponding index.</p><pre>let fruits=[&quot;Apple&quot;,&quot;Mango&quot;,&quot;Banana&quot;];<br>fruits[0]=&quot;Grapes&quot;;<br>console.log(fruits);</pre><p><strong>Common Array Methods</strong></p><p>1.push() -&gt;Add element at the end of an array and increases array length.</p><pre>let num=[1,2];<br>num.push(7);</pre><p>2.pop()-&gt;Remove last element from an array and reduce its length.</p><pre>let num=[1,2,7];<br>num.pop(2);</pre><p>3.shift()-&gt;Removes the first element from the array and returns it.</p><pre>let num=[1,2,7]<br>num.shift();</pre><p>4.unshift()-&gt;Add element to the beginning of an array.</p><pre>let num=[1,2,7];<br>num.unshift(3);</pre><p>Shift and unshift are working on the beginning of the arrays.</p><p>5.splice()-&gt;A versatile method that add or remove elements from any position of an array.</p><pre>let colour=[&quot;Red&quot;,&quot;Green&quot;,&quot;Black&quot;,&quot;Blue&quot;];<br>colour.splice(0,1); / / Removes 2 elements starting from index 0</pre><p><strong>Looping Through Arrays</strong></p><p>We can iterate array and access array elements using for loop (oldest way).</p><pre>let colour=[&quot;Red&quot;,&quot;Green&quot;,&quot;Black&quot;,&quot;Blue&quot;];<br>for(let i=0;i&lt;colour.length;i++)<br>{<br>console.log(colour[i]);<br>}</pre><p><strong>Real-Life Example</strong></p><p>· To-Do list App</p><p>· Students Marks list</p><p>· Shopping cart</p><p>· Playlist in music app</p><p>Means anywhere you see a list of similar items in real life, array are used in programming.</p><p><strong>Multidimensional Array</strong></p><p>Array inside array.</p><pre>let matrix=[<br>[1,2],[3,4]<br>];</pre><p><strong>Beginner Mistakes to avoid</strong></p><p>· Forgetting index starts from 0.</p><p>· Using wrong methods</p><p>· Forgetting arrays can change</p><p>· Accessing index that does not exist</p><p><em>Array is one of the most used data structures in JavaScript</em></p><p><em>Many real-world features like lists, carts, user data uses arrays.</em></p><p><strong>Practice Questions</strong></p><p>1.Print array length</p><p>2.Add one color using push ()</p><p>3.Remove last element from fruit array.</p><p>Arrays are one of the most Important concepts in JavaScript. They help you to store and manage multiple values easily. Arrays are dynamic we can add or remove elements easily in arrays like our shopping cart.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3b4713f27e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strings in JavaScript (Complete beginner guide with examples)]]></title>
            <link>https://medium.com/@swtigrwal21/strings-in-javascript-complete-beginner-guide-with-examples-066ee9f109ae?source=rss-752f30e3e50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/066ee9f109ae</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[strings-in-javascript]]></category>
            <category><![CDATA[practice-questions]]></category>
            <category><![CDATA[begginer-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Swati Agrawal]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 06:15:47 GMT</pubDate>
            <atom:updated>2026-02-12T06:15:47.159Z</atom:updated>
            <content:encoded><![CDATA[<p>When we are learning JavaScript, one of the most commonly used primitive data type you will work with is Strings. Strings are used to store and manipulate text such as name, addresses, messages and more. Strings are not just a text holders, but they provide us many built-in methods to search, modify or extract text efficiently.</p><p>In JavaScript strings are immutable means original string does NOT change. After any modification operation methods always return a new string.</p><p>Here we will understand strings in easy and simple way with example.</p><p><strong>How to create Strings?</strong></p><p>We can create a string using a quote. But JavaScript allows us three ways to create strings.</p><p><strong>1.Double Quotes</strong></p><p>let name = “Aliysha”;</p><p><strong>2.Single Quotes</strong></p><p>let city = ‘London’;</p><p><strong>3.Backticks(Template Literals)</strong></p><p>let name = “Aliysha”;</p><p>let text=’hello${name}’;</p><p><em>Backticks allow variable embedding and multi-line strings.</em></p><p><em>Both single (‘ ‘) and double (“ “) quotes work. Just be consistent only with one.</em></p><p><strong>String Methods in JavaScript</strong></p><p>Strings have their own built-in variables and functions, also known as methods. Here are some of the most common ones are.</p><ol><li><strong>length Property</strong>: Returns length of strings means number of characters in String.</li></ol><pre>let text=&quot;JavaScript&quot;;<br>console.log(text.length);</pre><p><em>Space are also count.</em></p><p><strong>2.Accessing String Characters</strong>: Strings use index number starting from 0 and using this we access characters from string.</p><pre>let text=&quot;JavaScript&quot;;<br>console.log(text[1]);</pre><p><strong>3.toUpperCase():</strong></p><p>Convert string characters in upper case (capital letters).</p><pre>let text=&quot;hello&quot; ;<br>console.log(text.toUpperCase());</pre><p><strong>4.toLowerCase():</strong></p><p>Convert string characters in lowercases (small letters).</p><pre>let text=&quot;HELLO&quot;;<br>console.log(text.toLowerCase());</pre><p><strong>5.trim():</strong></p><p>Remove extra spaces.</p><pre>let text=&quot; Swati  &quot; ;<br>console.log(text.trim());</pre><p><strong>6.slice():</strong></p><p>Extracts parts of string.</p><pre>let text =&quot;JavaScript&quot;;<br>console.log(text.slice(0,5);</pre><p><strong>7.replace():</strong></p><p>Replaces part of string.</p><pre>let text=&quot;Hello World&quot;;<br>console.log(text.replace(&quot;World&quot;,&quot;JavaScript&quot;);</pre><p><strong>8.includes():</strong></p><p>Checks if value exists in string.</p><pre>let text=&quot;JavaScript is nice&quot;;<br>console.log(text.includes(&quot;nice&quot;);</pre><p><strong>9.indexOf():</strong></p><p>It is used to find the position (index) of specific character or substring.</p><pre>let text=&quot;JavaScript is amazing&quot;;<br>console.log(text.indexOf(is));</pre><p><em>It returns the first occurrence of the value and if value is not found ,it returns -1.</em></p><p><strong>String Concatenation (Joining Strings)</strong></p><p>Using + we can join strings.</p><pre>let firstName=&quot;Swati&quot;;<br>let lastName=&quot;Agrawal&quot;;<br>let fullName=firstName+&quot; &quot;+lastName;</pre><p><strong>Concatenation using template literals (modern way)</strong></p><pre>let fullName=&#39;${firstName}${lastName}&#39;;</pre><p>Recommended in modern JavaScript.</p><p><strong>Escape Characters</strong></p><p>Used when you need quotes inside strings.</p><pre>let textT = &quot;he \&#39;says hi&quot;;<br>console.log(textT);</pre><p><strong>Multi-Line Strings</strong></p><p>Using backticks.</p><pre>let text1=`Hello <br>Welcome To <br>JavasCript`;<br>console.log(text1);</pre><p><strong>Real-Life use cases of string</strong></p><p>· From input values</p><p>· Display messages</p><p>· Usernames and passwords</p><p>· Searching</p><p><strong>Common Beginner Mistakes</strong></p><p>· Forgetting quotes</p><p>· Confusing numbers and strings</p><p><strong>When to use strings?</strong></p><p>Use strings whenever you work with-</p><p>· Names</p><p>· Text messages</p><p>· Address</p><p>· Emails</p><p>· Website content</p><p>Strings are one of the most used datatypes in JavaScript. Mastering string methods will help you to handle text efficiently in real-world applications.</p><p><strong>Practice Questions:</strong></p><p>1. Given a String Str, create a new String in which the last character has been removed. Display the new string in the console like.</p><p>Str=Apple New Str=Appl</p><p>2. Given a String str, count the number of A in it like.</p><p>Str=AmaAcbdA Number of A=3</p><p>3. Given a string Str, print all the digits in the string on the console like.</p><p>Str=A98%*np732 Digits=98732</p><p>Keep Learning and experimenting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=066ee9f109ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Functions in JavaScript (Beginner-Friendly Guide)]]></title>
            <link>https://medium.com/@swtigrwal21/functions-in-javascript-beginner-friendly-guide-6092373f1ca2?source=rss-752f30e3e50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6092373f1ca2</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[functions-in-javascript]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Swati Agrawal]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 08:13:01 GMT</pubDate>
            <atom:updated>2026-02-04T08:13:01.558Z</atom:updated>
            <content:encoded><![CDATA[<p>When we write JavaScript program often repeat the same code or logic again and again. Instead of repeating a same code and logic JavaScript gives us functions to make our code clean, reusable and easy to understand.</p><p>In this article ,we will learn about functions step by step with simple and clear examples.</p><p><strong>What is function?</strong></p><p>A function is a block of code that are used to perform a specific task. Function provide better modularity and high degree of code reusability.</p><p>In simple words: A function is a piece of code that runs when we call it.</p><p>A <strong>function</strong> is a <strong>reusable block of code</strong> that:</p><ul><li>Takes data or input (optional)</li><li>Does some work on that data</li><li>Returns output/result (optional)</li></ul><p>Real-Life Examples:</p><p>· A calculator function for adding numbers</p><p>· A form validation checks for every new user</p><p>· A washing machine that performs a same step every time when we use it.</p><p><strong>Why Do we need functions?</strong></p><p>· Avoid code repetition</p><p>· Make debugging easier</p><p>· Easy to understand code (readable)</p><p>· Make code reusable</p><p>· Divide long code into a small piece</p><p>Without functions our code become long and messy.</p><p><strong>Function Syntax:</strong></p><p>function functionName(){</p><p>//block of code</p><p>}</p><p>Here</p><p>function — keyword (reserve word)</p><p>functionName- Name of function</p><p>()- where we may pass a parameters</p><p>{}- function body where we write our code</p><p><strong>Function declaration and Function calling :</strong></p><pre>function greet (){<br>console.log (“good morning”);<br>}<br><br>greet ();//function calling</pre><p><em>A function runs only when we call it. Nothing happens until you </em><strong><em>call</em></strong><em> the function.</em></p><p><strong>Output:</strong></p><p>good morning</p><p><strong>Function with parameters and Arguments:</strong></p><pre>function add(a,b)      //add is function name where a,b are parameters<br>{<br>console.log(a+b);<br>}<br>add(7,3);        //calling function add with 2 arguments</pre><p><strong>Parameters </strong>are placeholders and<strong> Arguments </strong>are real values that we passed<strong>.</strong></p><p>Here a, b is parameter and 7,3 is arguments.</p><p><strong>Default Values/Parameters in Function:</strong></p><p>If user does not give values, then we pass a function to some default values (parameters) these values are call default Parameters.</p><p>Real-Life Example: Think we order pizza and not choose spice level then restaurant use medium spice level as a default and deliver our pizza.</p><p><strong>Example:</strong></p><pre>function add(a=0, b=0){<br>console.log(a+b);<br>}<br>add();</pre><p>Here output is 0;</p><p><strong><em>Default values are used only when we are not passed values or value is undefined.</em></strong></p><p><strong>Function with Return Value:</strong></p><p>In a function body, we often use a return statement to send data back to user. A return statement returns one specific value and stops the function execution. Means after the return statement function not going to execute any code. That’s why the return statement should always be in last.</p><p>Example:</p><pre>function add(a,b){<br>return a+b;<br>}<br>let result=add(5+7);<br>console.log(result);</pre><p><strong><em>Once return is executed, the function stops running.</em></strong></p><p><strong>Function Expression:</strong></p><p>Function can also be stored inside a variables this type of function we call function expression this are anonymous or without name functions.</p><p>Example:</p><pre>const multiply=function(a,b){<br>return a*b;<br>};<br>console.log(multiply(4,3));</pre><p><strong>Arrow Function:</strong></p><p>Arrow function expressions were introduced in ES6.These is the short and modern way to write functions. Arrow function expressions are clean and concise. The syntax for an arrow function expression does not require the function keyword. They use a fat arrow =&gt; that’s why we call it arrow function.</p><p>Syntax:</p><p>let myArrowFunction = (arg1, arg2, …argN) =&gt; {</p><p>//code or statement(s)</p><p>}</p><p>Here,</p><ul><li>myArrowFunction is the name of the function.</li><li>arg1, arg2, …argN are the function arguments.</li><li>statement(s) is the function body.</li></ul><p>If the body has single statement or expression, you can also write the arrow function in one line like:</p><p>let myArrowFunction=(arguments)=&gt;expression;</p><p>Example:</p><pre>const square=(num)=&gt;{<br>return num*num;<br>}<br>console.log(square(5));</pre><p>In one line</p><pre>Const square=num=&gt;num*num;</pre><p><strong>Best Practices for Writing Functions</strong></p><ul><li>✅ Keep functions small and focused</li><li>✅ Use meaningful names</li><li>✅ Avoid excessive parameters</li><li>✅ Prefer pure functions when possible</li><li>✅ Use arrow functions wisely</li></ul><p><strong>Common Beginner Mistakes?</strong></p><p>❌ Forgetting return keyword<br> ❌ Not passing required values or parameters<br> ❌ Wrong parameter order<br> ❌ forgetting function calling</p><p><strong>Practice Questions:</strong></p><p>1.create a function to add 3 numbers also pass default values.</p><p>2.create arrow function in one line to find cube of number.</p><p>3.write down the difference between function expression and function declaration.</p><p><strong>Conclusion</strong></p><p>Functions are the heart of JavaScript. They help us to write clean, efficient, and scalable code. If you understand functions well, <strong>you understand JavaScript</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6092373f1ca2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Loops in JavaScript Explained Simply (With Examples)]]></title>
            <link>https://medium.com/@swtigrwal21/loops-in-javascript-explained-simply-with-examples-3e97d400bbe9?source=rss-752f30e3e50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e97d400bbe9</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[begginers-guide]]></category>
            <category><![CDATA[loops-in-javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Swati Agrawal]]></dc:creator>
            <pubDate>Mon, 02 Feb 2026 06:57:41 GMT</pubDate>
            <atom:updated>2026-02-02T06:57:41.890Z</atom:updated>
            <content:encoded><![CDATA[<p>When writing program often we need to repeat the same task multiple times. We know that writing the same code for multiple time is not good practice. This is where<strong> loops</strong> come into a programming language.</p><p>In this article, we’ll understand <strong>loops in JavaScript</strong> in simple, beginner-friendly way with clear and real-life examples.</p><p><strong>What is a Loop?</strong></p><p>A loop allows us to execute a block of code repeatedly as long as a given condition is true means runs the same code again and again until the condition is false.</p><p><strong>In Real Life:</strong></p><p>· Counting Numbers from 1 to 100</p><p>· In list of students check pass or fail</p><p>· Total the marks of marksheets</p><p>· Repeat an action until a condition become false</p><p><strong>Why do we need loops?</strong></p><p>Without loops, we would have to write the same code multiple times. For example if we want to print 1 to 5 counting on console we must write</p><p>console.log(1);</p><p>console.log(2);</p><p>console.log(3);</p><p>console.log(4);</p><p>console.log(5);</p><p>But if we have a loop then no need to repeat console.log 5 times.</p><p>Instead of we use</p><pre>for(let i=1;i&lt;=5;i++){<br>console.log(i)<br>}</pre><p>And we got the output. It make our code clear and easy to understand.</p><p><strong>Types of Loops in JavaScript</strong></p><p>JavaScript provides the following main loops:</p><p>1.for loop</p><p>2.while loop</p><p>3.do…while loop</p><p><strong>Specialized Loops after ES6</strong></p><p>4.for…of</p><p>5.for…in</p><p>Let’s understand all of them one by one.</p><p><strong>1.for Loop:</strong></p><p><strong>This loop</strong> is used when we know how many times the loop should run and what is its initial value.</p><p><strong>Syntax:</strong></p><p>for(initialization ;condition checking; increment/decrement){</p><p>//code(statements)</p><p>}</p><p><strong>Example:</strong></p><pre>for(let i=1;i&lt;=10;i++)<br>{<br>console.log(i);<br>}</pre><p><strong>How it Works</strong></p><ul><li>initialize → condition Checking → run → increment</li><li>Output: 1 2 3 4 5 6 7 8 9 10</li></ul><p>Here in for loop first we give a initial value then we check the condition if given condition is true then it execute a block of code then we increment/decrement the value again it checks condition and execute the block of code these types of iterations we know the loops and for loops iterate until the condition it not false.</p><p>· Let i=1 means starts from 1</p><p>· i&lt;=10 means run until i is not grater then 10</p><p>· i++ means increases value by 1</p><p><strong><em>It is best for counting loops.</em></strong></p><p><strong>2.while loop:</strong></p><p>It is used when the number of iterations is not fixed.it runs as long as the given condition is true.</p><p><strong>Syntax:</strong></p><p>while(condition){</p><p>//statement</p><p>}</p><p><strong>Example:</strong></p><pre>let i=0;<br>let j=1;<br>while(j&lt;5){<br>i=i+j;<br>j++;<br>console.log(i,j);<br>}<br>console.log(i);</pre><p><strong>How it Works</strong></p><p>With each iteration, the loop increments j and adds that value to i. Therefore, i and j take on the following values:</p><ul><li>After the first pass: i = 1 and j = 2</li><li>After the second pass: i = 3 and j = 3</li><li>After the third pass: i = 6 and j = 4 and so on.</li></ul><p>After completing the fifth pass, the condition j &lt;5 is no longer true, so the loop terminates.</p><p><strong><em>Always update the condition, otherwise it may cause an infinite loop.</em></strong></p><p><strong>3.do…while Loop:</strong></p><p>It is like while, but it runs at least once even the given condition is true/false because it checks condition after the block of code.</p><p><strong>Syntax:</strong></p><p>do{</p><p>//code</p><p>}while(condition);</p><p>If condition is true, the statement executes again. At the end of every execution, the condition is checked. When the condition is false, execution stops, and control passes to the statement following do…while.</p><p><strong>Example:</strong></p><pre>let i=6;<br>do{<br>console.log(i);<br>i++;<br>}while(i&lt;=5);</pre><p><em>It gives output 6 even given condition is false it runs once.</em></p><p><strong>4.for…of Loop</strong></p><p>Introduced in ES6, this loop is designed to iterate(loop) over the <em>values</em> of iterable objects like Arrays,Strings,Maps and Sets. It is highlighted as the modern, preferred way to loop through arrays.</p><p><strong>Syntax:</strong></p><p>for (let items of iterable){</p><p>//statement</p><p>}</p><p><strong>Example(Array):</strong></p><pre>const fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;mango&quot;];<br><br>for (const fruit of fruits) {<br>  console.log(fruit);<br>}</pre><p><strong>Example(String):</strong></p><pre>for(let char of &quot;JS&quot;)<br>{<br>console.log(char);<br>}</pre><p><strong><em>Best for Values.</em></strong></p><p><strong>5.for…in Loop:</strong></p><p>Used to loop through the object properties(keys).</p><p><strong>Syntax:</strong></p><p>for(let key in object){</p><p>//code</p><p>}</p><p><strong>Example:</strong></p><pre>let student={name:”ABC”;age:21,course:”JavaScript};<br>for(let key in student){<br>console.log(key+” ”+student[key]);<br>}</pre><p><strong>Here output is:</strong></p><p>name: ABC</p><p>age:21</p><p>course: JavaScript</p><p><strong>Loop Control Statements</strong></p><p><strong><em>Break</em></strong><em>: Stops the loop completely.</em></p><p><strong><em>Continue</em></strong><em>: Skips the current iterations.</em></p><p><strong>Which loop should you use?</strong></p><p><strong>Situations — — — — — — — — — — — — — — — — — — — Best Loops</strong></p><p>Array/Strings — — — — — — — — — — — — — — — — — — — -for…of</p><p>Objects(key value pair values) — — — — — — — — — — — -for…in</p><p>Must run code even condition is false — — — — — — — -do…while</p><p>Know the number of iterations — — — — — — — — — — - for</p><p>Condition-based — — — — — — — — — — — — — — — — — — while</p><p><strong>Common Beginner Mistakes</strong></p><p>· Forgetting to update conditions</p><p>· Using for…in for arrays</p><p>· Infinite loops</p><p>· Confusing for, for…of and for…in loops</p><p>· In for loop forgetting declaring i</p><p><strong>Final thoughts: Loops helps us to write less code and do more work.</strong></p><p><strong>Practice Questions:</strong></p><p>1.Find the sum of numbers from 1 to 100.</p><p>2.Which loop is best to iterate over an array and why?</p><p>3.Print all even number from 1 to 20;</p><p>4. Given n=15, print the following pattern on the console. Note that all the multiples of 5 have been denoted by @.</p><p>Pattern like<strong>: 6@4321</strong> if <strong>n=6;</strong></p><p>Keep Learning, Keep Experimenting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e97d400bbe9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conditional Statements in JavaScript (With Simple Examples)]]></title>
            <link>https://medium.com/@swtigrwal21/conditional-statements-in-javascript-with-simple-examples-a49114fc5817?source=rss-752f30e3e50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a49114fc5817</guid>
            <category><![CDATA[conditional-statements]]></category>
            <category><![CDATA[coding-for-beginners]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learn-to-code]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Swati Agrawal]]></dc:creator>
            <pubDate>Tue, 27 Jan 2026 13:04:14 GMT</pubDate>
            <atom:updated>2026-01-27T13:06:42.791Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Conditional Statements in JavaScript (With Simple Examples)</strong></p><p>When we write a program, often we need to make decisions based on some specific conditions. Sometimes a block of code should run only when a specific condition is true and sometimes a different block should run when its false. These conditions are usually based on comparisons, logical expressions, or user input.</p><p>This is where Conditional Statement come into play.</p><p>In this article, we’ll understand conditional statements in JavaScript in a simple, beginner-friendly way with clear examples.</p><p><strong>What are Conditional statements?</strong></p><p>Conditional statements allow JavaScript to execute different block of code based on different conditions.</p><p><strong>Real life examples:</strong></p><p>· In traffic signals If the light is green, you go, if it’s red, you stop. Similarly, if a condition is true in code, one block should run otherwise, another block run.</p><p>· If marks are above 40 then pass otherwise fail.</p><p>· If number is positive, then print positive else negative.</p><p><strong>Why Conditional Statements Are Important</strong></p><p>Without conditional statements, a program would run in the same way every time. Conditional statements help JavaScript:</p><ul><li>Respond to user actions</li><li>Validate input</li><li>Make decisions</li><li>Control program flow</li></ul><p><strong>Types of Conditional Statements in JavaScript</strong></p><p>JavaScript provides the following conditions statements these are:</p><ol><li>if statement</li><li>if…else statement</li><li>else if statement</li><li>switch statement</li><li>Ternary (Conditional) Operator</li></ol><p>Let’s understand them one by one.</p><p><strong>1.if Statement</strong></p><p>The if statement executes a block of code only if the given condition is true.</p><p><strong>Syntax:</strong></p><p>if(condition){</p><p>//code to be execute</p><p>}</p><pre>Example:<br>let x=21;<br>if(x&gt;10){<br>console.log(&quot;number is lager then 10&quot;);<br>}</pre><p>If the condition is true, message will print.</p><p><strong>2. if…else statement</strong></p><p>The if…else statement executes a block of code based on conditions if the condition is true then print if block of code otherwise print an else block of code.</p><p><strong>Syntax:</strong></p><p>if(condition){</p><p>//code to be execute if condition true</p><p>}</p><p>else {</p><p>//code to be execute if condition is false</p><p>}</p><pre>Example:<br>let x=21;<br>if(x&gt;10){<br>console.log(&quot;number is lager then 10&quot;);<br>}<br>else{<br>console.log(&quot;number is smaller then 10&quot;);<br>}</pre><p><strong>3.else if statement</strong></p><p>We use this if we want to check multiple conditions. If we have more than two possible outcomes based on different conditions, then we use else if statements.</p><p><strong>Syntax:</strong></p><p>if(condition1) {</p><p>//code to be execute if condition1 is true</p><p>}</p><p>else if(condition2) {</p><p>//code to be execute if condition2 is true</p><p>}</p><p>else {</p><p>//all conditions are false(default)</p><p>}</p><pre>Example:<br>let x=21;<br>if(x&gt;10) {<br>console.log (&quot;number is lager then 10&quot;);<br>}<br>else if(x&lt;10){<br>console.log(&quot;number is smaller then 10&quot;);<br>}<br>else{<br>console.log(&quot;number is equal to 10&quot;);<br>}</pre><p><strong>4. switch statement</strong></p><p>The switch statement in JavaScript is a control structure that compares a single value against multiple possible cases. This is the alternative of too long else if statements, especially if we want to check one variable against different fixed values.</p><p>Means if we want to check a single expression for multiple cases then we use the switch statements.</p><p><strong>Syntax:</strong></p><p>switch(expression){</p><p>case value1:</p><p>//code</p><p>break;</p><p>case value2:</p><p>//code</p><p>break;</p><p>case value3:</p><p>//code</p><p>break;</p><p>default:</p><p>//default code(if none of the condition is follows)</p><p>}</p><pre>Example:<br>let  month=3;<br>switch(month){<br>case 1:<br>console.log(&quot;January&quot;);<br>break;<br>case 2:<br>console.log(&quot;February&quot;);<br>break;<br>case 3:<br>console.log(&quot;March&quot;);<br>break;<br>case 3:<br>console.log(&quot;April&quot;);<br>break;<br>default:<br>console.log(&quot;Not Known the given month&quot;);<br>}<br></pre><p><strong>Don’t forget to write break it stops the execution after the condition is matches.</strong></p><p><strong>5.Ternary (Conditional) Operator</strong></p><p>The ternary operator is a shorthand way to write if…else statements in a single line.</p><p><strong>Syntax:</strong></p><p>condition ? expression1 : expression2;</p><pre>  Example:<br>let num = 20;<br>let result = (num &gt;10) ? &quot;Larger&quot; : &quot;Smaller&quot;;<br>console.log(result);</pre><p><strong>Common Beginner Mistakes:</strong></p><p>· Forgetting curly braces {}</p><p>· Using = instead of == or ===</p><p>· Writing complex code without understanding of conditions and logics</p><p>· Missing break in switch cases</p><p>Conditional statements are the backbone of decision-making in any programming language. They help us to make code more dynamic, responsive and clear to understand.</p><p><strong>Quick Practise Questions:</strong></p><p>1. Given a number n. If n is a multiple of 5, display the message Multiple of 5, otherwise display Not a Multiple of 5 in the console.</p><p>2. If we have a single condition to check, then which conditional statement should we use?</p><p>3. In comment section send some switch conditional statement examples.</p><p>Keep practicing, keep experimenting and happy learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a49114fc5817" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Operators for Beginners(With Practice Questions)]]></title>
            <link>https://medium.com/@swtigrwal21/javascript-operators-for-beginners-with-practice-questions-7c919eb022d8?source=rss-752f30e3e50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c919eb022d8</guid>
            <category><![CDATA[coding-for-beginners]]></category>
            <category><![CDATA[javascript-operators]]></category>
            <category><![CDATA[javascript-basics]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Swati Agrawal]]></dc:creator>
            <pubDate>Fri, 23 Jan 2026 07:45:19 GMT</pubDate>
            <atom:updated>2026-01-23T07:45:19.355Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>JavaScript Operators for Beginners(With Practice Questions)</strong></p><p>Operators are special symbols that are used to perform a specific task on values and variables.</p><p>In simple words: Operators help us to calculate or compares values and make decisions in our program.</p><p><em>Eg:</em></p><p><em>let sum=20+2;</em></p><p>Here:</p><p>· + is operator (which operation we perform)</p><p>· 20 and 2 is operands (on that values we perform operations)</p><p>· Sum is variable which store the result (where we store result)</p><p><strong>Why operators are important in programming</strong></p><p>In any programming language variables are just store a data but if we want to perform some operations on that data then we need an operator.</p><p>Operators help us to:</p><p>· Do Calculations (billing, marksheet)</p><p>· Compare values (voting age, conditions)</p><p>· Make decisions (if else)</p><p>· Combine text(alerts, messages)</p><p>· Control program logics</p><p><em>Eg:let a=1;</em></p><p><em>let b=2;</em></p><p>Here we have a data or values, but what we will do?</p><p>Operators make them useful and allow us to perform a specific task like addition, subtraction or comparison also operators are making any programming language to a dynamic and using them we create logics.</p><p><strong>JavaScript Operator Types</strong></p><p>Based on the operations we divide operators in different types. Here is a list of some JavaScript operators you will learn in this article:</p><ol><li>Arithmetic Operators</li><li>Assignment Operators</li><li>Comparison Operators</li><li>Logical Operators</li><li>Unary Operators</li><li>Ternary Operators</li><li>Bitwise<strong> </strong>Operators</li></ol><p><strong>Arithmetic Operators</strong></p><p>The arithmetic operators are used to perform mathematical calculations like addition, subtraction etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*bWRh0xiNzOclp0wByuCrIg.png" /></figure><p><em>Eg:</em></p><p><em>let a=10;</em></p><p><em>let b=3;</em></p><p><em>console.log(a**b);</em></p><p><em>console.log(a%b);</em></p><p><strong>Assignment Operators</strong></p><p>We use assignment operators to <strong>assign or update</strong> values to variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*5IJQvIkpxbJ9H4wzZRWdgw.png" /></figure><p><em>Eg:</em></p><p><em>let price=100;</em></p><p><em>price+=20;</em></p><p><em>console.log(price);</em></p><p><strong>Comparison Operators</strong></p><p>We use comparison operators to compare two values and return a Boolean value which is true or false.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*iJNOP43-YiF4n3FLEV2PGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*_bwiewfNn_tg5_zZJxgE5Q.png" /></figure><p><strong>Difference between strict equality and loose equality are loose equality only convert values (not type) in common type of values and compare them but strict equality convert values and type both and then compare two values.</strong></p><p>Example:</p><p><em>let n1=25;</em></p><p><em>let n3=’25&#39;;</em></p><p><em>console.log(‘loosequality’,n1==n3);</em></p><p><em>console.log(‘strictequality’,n1===n3);</em></p><p><strong>Note: Always prefer === (strict equality)instead of ==(loose equality).</strong></p><p><strong>Logical Operators</strong></p><p>We use this operator to combine conditions and perform logical operations on Boolean expressions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*jZC9DTFPUnKmt7PsA3f-WQ.png" /></figure><p><strong><em>Eg:</em></strong></p><p>let age=21;</p><p>let id=true;</p><p>console.log(age&gt;18 &amp;&amp; id);</p><p><strong>Unary Operators</strong></p><p>This operator are operating on a single value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*dXZ1X3e3uUo43kVdFJjnGw.png" /></figure><pre>example:<br>let a=5;<br>console.log(typeof a);</pre><p><strong>Ternary Operators</strong></p><p>The ternary operator is also called the conditional operator this is only JavaScript operator that requires 3 operands to run this is short form of if-else<strong>.</strong></p><p>Syntax is:</p><p>condition ? expression1 : expression2</p><ul><li>If the condition is true, expression1 is executed.</li><li>If the condition is false, expression2 is executed.</li></ul><pre>Example:<br>let age=16;<br>let result=age&gt;=18 ? &quot;adult&quot; : &quot;minor&quot;;<br>console.log(result);</pre><p><strong>Bitwise Operators(Advanced)</strong></p><p>Bitwise Operators work on bits means on binary number (0 ans1) instead of normal numbers.</p><p>These operators used on web development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*lufLYqXy688lven6nWFaOA.png" /></figure><p><strong>Common beginner mistakes</strong></p><p>· Using == instead of === for compare values</p><p>· Ignoring type conversion(coercion) means if you write “5”+2 it gives 52 not sum 7.be careful mixing string and numbers.</p><p>· Misunderstanding logical operators means &amp;&amp; and || return values also not always return true or false.</p><p>· Forgetting operator precedence means use parentheses () to avoid unexpected results.</p><p>· Writing complex expressions means writing</p><p>if(a&gt;10 &amp;&amp; b&lt;5 || c===3) {}</p><p>instead of readable like</p><p>let isValid=(a&gt;10 &amp;&amp; b&lt;5) || c===3;</p><p>If(isValid){}</p><p>Focus on clarity over cleverness. Simple and readable code is always better than complex expressions.</p><p><strong>Final thought</strong></p><p>Understanding operators helps you to write correct and readable JavaScript code, Avoiding these common mistakes will save you from many bugs as a beginner.</p><p><strong>Practice Question and answer in comment section:</strong></p><p><strong>1.</strong> What will be the output of <strong>console.log(‘5’+5) </strong>?</p><p><strong>2.</strong> What is the result <strong>of console.log(true &amp;&amp; false || true);</strong></p><p><strong>3.</strong> Predict the output:</p><p><strong>console.log(0==false);</strong></p><p><strong>console.log (0===false);</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c919eb022d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understating Variables and Data Types-A Beginner’s Guide]]></title>
            <link>https://medium.com/@swtigrwal21/understating-variables-and-data-types-a-beginners-guide-a1fd31eb2219?source=rss-752f30e3e50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1fd31eb2219</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[datatypes-in-javascript]]></category>
            <category><![CDATA[javascript-variable]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[proggraming]]></category>
            <dc:creator><![CDATA[Swati Agrawal]]></dc:creator>
            <pubDate>Mon, 12 Jan 2026 13:08:40 GMT</pubDate>
            <atom:updated>2026-01-12T13:08:40.941Z</atom:updated>
            <content:encoded><![CDATA[<p>Understating Variables and Data Types-A Beginner’s Guide</p><p><strong>Variables in JavaScript</strong></p><p>Like any other programming languages variables are work as a container which are hold some values that are may be changed same as in JavaScript variables are container which contains value and that value can change.</p><p>Real-life example:In every kitchen container riseQuantity hold 5kg of rise and after cooking it is 4kg here riseQuantity is work as a variable.</p><p><strong>In JavaScript variables are declare by these 3 ways:</strong></p><p>Using <strong>let, var</strong> and <strong>const.</strong></p><p><strong>1.let</strong></p><p>-Modern and recommended</p><p>-Block-scoped and can be updated</p><p>-Redeclared but not in same block</p><p>Eg: let riseQuantity=4 ;</p><p>riseQuantity=3;</p><p><strong>2.var</strong></p><p>-Old-way (used before ES6)</p><p>-Function-scoped(only accessible in functions)</p><p>Eg:var city=”Delhi”;</p><p><strong>3.const</strong></p><p>-Block-scoped</p><p>-value cannot be reassigned</p><p>Eg:const country=”India”;</p><p><strong>Rules for naming variables in JavaScript:</strong></p><p>-Not a reserve keyword</p><p>-Cannot start with number</p><p>-Cannot have a space or –(hyphen)</p><ul><li>Case sensitive</li></ul><p><strong>Good practices for naming variables are</strong></p><p>-Meaningful</p><p>-CamelCase</p><p>Eg:-firstName,large_Data,dateOfBirth;</p><blockquote>var globalVar=”rice”;//Global Scope(Exists everywhere)</blockquote><blockquote>function test(){<br>var localVar=”boiled”;//Funtion Scope(Exists inside function only)</blockquote><blockquote>console.log(globalVar); //rise<br>console.log(localVar); //boiled</blockquote><blockquote>function inside(){<br>console.log(localVar); //Lexical Scope(Child function able to access parent )<br>}</blockquote><blockquote>for(let i=0;i&gt;3;i++) //Block Scope(Exists only in block of code)<br>{<br>console.log(globalVar);//rise<br>console.log(localVar);//boiled<br>console.log(i);//0,1,2<br>}<br>console.log(i);//ERROR<br>}<br>console.log(globalVar);//rice<br>console.log(localVar);//ERROR<br>console.log(i);//ERROR</blockquote><p><strong>Data Types in JavaScript</strong></p><p><em>It tells what kind of value a variable is storing.</em></p><p><strong>Types of Data in JavaScript</strong></p><p><strong>A.Primitive:-</strong></p><p><strong>1.Number</strong>-store number integer or decimal</p><p>Eg: age,marks,price</p><p>let num=10</p><p><strong>2.String</strong>-used to store textual data</p><p>Eg: let str=”10”;</p><p><strong>3.Boolean</strong>- any value true or false</p><p><strong>4.Undefined</strong>-if cannot defined a variable it is undefined</p><p>Eg: let js; //output is undefined</p><p>5.Null- denoted a null value</p><p><strong>6.Symbol</strong>-it is unique and immutable</p><p>Eg: let value=Symbol(‘something’);</p><p><strong>B.Non-Primitive or Reference:-</strong></p><p><strong>1.Array</strong>-store ordered collection of values.</p><p>[1,”hi”,false]</p><p><strong>2.Object</strong>-store value in key-value pairs</p><p>{key:’value’}</p><p><strong>3.Function</strong>-block of reusable code use to perform a specific task.</p><p>Eg:function greet(name){</p><p>Return “hi,”+name</p><p>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1fd31eb2219" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to JavaScript for Beginners]]></title>
            <link>https://medium.com/@swtigrwal21/introduction-to-javascript-for-beginners-700444b0983f?source=rss-752f30e3e50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/700444b0983f</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[easyprogramming]]></category>
            <category><![CDATA[ecmascript]]></category>
            <dc:creator><![CDATA[Swati Agrawal]]></dc:creator>
            <pubDate>Thu, 01 Jan 2026 08:43:19 GMT</pubDate>
            <atom:updated>2026-01-01T08:43:19.718Z</atom:updated>
            <content:encoded><![CDATA[<p>Introduction to JavaScript for Beginners</p><p><strong>What is Programming?</strong></p><p>Programming is a way to communicate with computer like for communicate with persons we need a languages like Hindi , English ,chines or etc. similarly if we want to talk to computer we need a languages like Java, C++ ,JavaScript etc.</p><p><strong>What is JavaScript/ECMAScript?</strong></p><p>ECMAScript is a standard or specification that defines how JavaScript should work.</p><p>In other words it is rulebook of JavaScript where anyone can add new concepts or chapter of JavaScript and those are accessible for all in a same manner.</p><p>JavaScript is high level interpreted (translate what somebody is saying into another language ) programming language used to add interactive(user friendly) web pages. It is most popular and widely used programming language. It’s used to build a applications by most of the large companies like google, amazon ,Facebook etc. It is has a most carrier options like you can become a front end developer, backend developer or full stack developer (both frontend and backend) if you have a knowledge.</p><p>Today It is used for variety of purposes most important of them are mobile and web applications, games, networking and chat apps and all the server side backed tools.</p><p>As we know it used create a interactive web pages in browsers so initially it is run on browsers infect every web browser has a JavaScript engine .In Chrome it is V8 engine ,in Firefox it is spiderMonkey and Microsoft and internet explorer is chakra.</p><p>In 2009 An engineer took the JavaScript engine V8 and embedded in a c++ program and create a program called node and this program(Node) allows us to run JavaScript code outside the browser. Node is widely used for backend for web and mobile apps.</p><p><strong>Where we can Run the Code?</strong></p><p><strong>Using the Browser Console</strong></p><p>Open your browser (Chrome, Firefox, etc.), press Ctrl + Shift + J (or Cmd + Option + J on Mac), and you’ll see the Console or simply right click on mouse and click on inspect now you can see see console.</p><p>You can write JavaScript directly there!</p><blockquote>console.log(“Hello, world!”);</blockquote><p><strong>Writing Code in a nots or file</strong></p><p>Save this code in a file named firstCode.html and open it in your browser:</p><blockquote>&lt;!DOCTYPE html&gt;<br> &lt;html&gt;<br> &lt;head&gt;<br> &lt;title&gt;My First JavaScript&lt;/title&gt;<br> &lt;/head&gt;<br> &lt;body&gt;<br> &lt;h1&gt;Hello, JavaScript!&lt;/h1&gt;<br> &lt;script&gt;<br> console.log(“This is my first script!”);<br> &lt;/script&gt;<br> &lt;/body&gt;<br> &lt;/html&gt;</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=700444b0983f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>