<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Javascript Archives -</title>
	<atom:link href="https://careersknowledge.in/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://careersknowledge.in/category/javascript/</link>
	<description></description>
	<lastBuildDate>Sat, 13 Apr 2024 13:51:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>Local and Global Variables in JavaScript</title>
		<link>https://careersknowledge.in/local-and-global-variables-in-javascript/</link>
					<comments>https://careersknowledge.in/local-and-global-variables-in-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Sat, 13 Apr 2024 13:51:39 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[global scope in javascript]]></category>
		<category><![CDATA[Local and Global Variables in JavaScript]]></category>
		<category><![CDATA[local and global variables in javascript with example]]></category>
		<category><![CDATA[local variable in javascript]]></category>
		<category><![CDATA[types of variables in javascript]]></category>
		<category><![CDATA[What is difference between global and local variable?]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1551</guid>

					<description><![CDATA[<p>Local and Global Variables in JavaScript In the realm of JavaScript programming, variables play a pivotal role in storing and manipulating data. They act as placeholders for values that can be referenced and modified throughout a program. However, not all variables are created equal. In JavaScript, variables are categorized into two main types: local variables ... <a title="Local and Global Variables in JavaScript" class="read-more" href="https://careersknowledge.in/local-and-global-variables-in-javascript/" aria-label="Read more about Local and Global Variables in JavaScript">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/local-and-global-variables-in-javascript/">Local and Global Variables in JavaScript</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1 style="text-align: center;"><strong><span style="color: #000000;">Local and Global Variables in JavaScript</span></strong></h1>
<p><span style="color: #000000;">In the realm of JavaScript programming, variables play a pivotal role in storing and manipulating data. They act as placeholders for values that can be referenced and modified throughout a program. However, not all variables are created equal. In JavaScript, variables are categorized into two main types: local variables and global variables. Understanding the distinction between these two types is essential for writing efficient and maintainable code.</span></p>
<h3><strong><span style="color: #000000;">Local Variables</span></strong></h3>
<p><span style="color: #000000;">Local variables are declared within a specific scope, typically within a function. These variables are accessible only within the block of code in which they are defined. Once the function execution is complete, local variables cease to exist, and their values are no longer accessible. This encapsulation helps prevent naming conflicts and promotes modularity in code.</span></p>
<p><span style="color: #000000;">function myFunction() {</span><br />
<span style="color: #000000;">var localVar = 10;</span><br />
<span style="color: #000000;">document.write(localVar); // Output: 10</span><br />
<span style="color: #000000;">}</span></p>
<p><span style="color: #000000;">myFunction();</span><br />
<span style="color: #000000;">document.write(localVar); // Error: localVar is not defined</span></p>
<p><span style="color: #000000;">In the example above, <code>localVar</code> is declared inside the <code>myFunction()</code> function, making it a local variable. It can be accessed and modified only within the function.</span></p>
<h3><strong><span style="color: #000000;">Global Variables</span></strong></h3>
<p><span style="color: #000000;">On the other hand, global variables are declared outside of any function and are accessible from anywhere within the script. They have a global scope, meaning they can be accessed by any function or block of code in the entire script. While global variables offer convenience in terms of accessibility, they also come with certain drawbacks. They can lead to naming conflicts, increase the risk of unintended side effects, and make it challenging to understand and maintain code.</span></p>
<p><span style="color: #000000;">var globalVar = 20;</span></p>
<p><span style="color: #000000;">function myFunction() {</span><br />
<span style="color: #000000;">document.write(globalVar); // Output: 20</span><br />
<span style="color: #000000;">}</span></p>
<p><span style="color: #000000;">myFunction();</span><br />
<span style="color: #000000;">document.write(globalVar); // Output: 20</span></p>
<p><span style="color: #000000;">In this example, <code>globalVar</code> is declared outside of any function, making it a global variable. It can be accessed from both inside and outside of the function <code>myFunction()</code>.</span></p>
<h2 class="s75CSd u60jwe r2fjmd AB4Wff" style="text-align: center;"><strong><span style="color: #000000;">local and global variables in javascript with example</span></strong></h2>
<p><span style="color: #ff0000;"><strong>Example 1-</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;head&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var a=1000;//global variable</span><br />
<span style="color: #000000;">function MyFun()</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">var a=200;//local varible</span><br />
<span style="color: #000000;">document.write(&#8220;value of a in local scope=&#8221;+a+&#8221;&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/head&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">document.write(&#8220;value of a in global scope=&#8221;+a+&#8221;&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">MyFun();</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;">value of a in global scope=1000</span><br />
<span style="color: #000000;">value of a in local scope=200</span></p>
<p><span style="color: #ff0000;"><strong>Example-2</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;head&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">//how global variable used in local scope </span><br />
<span style="color: #000000;">var a=1000;//global variable</span><br />
<span style="color: #000000;">var b=2000;</span><br />
<span style="color: #000000;">function MyFun()</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">var a=200;//local varible</span><br />
<span style="color: #000000;">document.write(&#8220;value of a in function =&#8221;+a+&#8221;&lt;br&gt;&#8221;);//200</span><br />
<span style="color: #000000;">document.write(&#8220;value of b in function =&#8221;+b+&#8221;&lt;br&gt;&#8221;);//2000</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/head&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">document.write(&#8220;value of a before function calling=&#8221;+a+&#8221;&lt;br&gt;&#8221;);//1000</span><br />
<span style="color: #000000;">document.write(&#8220;value of b before function calling=&#8221;+b+&#8221;&lt;br&gt;&#8221;);//2000</span><br />
<span style="color: #000000;">MyFun();</span><br />
<span style="color: #000000;">document.write(&#8220;value of a after function calling=&#8221;+a+&#8221;&lt;br&gt;&#8221;);//1000</span><br />
<span style="color: #000000;">document.write(&#8220;value of b after function calling=&#8221;+b+&#8221;&lt;br&gt;&#8221;);//2000</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-1552" src="http://careersknowledge.in/wp-content/uploads/2024/04/variablescope.png" alt="" width="577" height="243" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/variablescope.png 577w, https://careersknowledge.in/wp-content/uploads/2024/04/variablescope-324x136.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/variablescope-300x126.png 300w" sizes="(max-width: 577px) 100vw, 577px" /></span></p>
<h3><strong><span style="color: #ff0000;">For Live Class Watch Full Video on youtube by click on the below link</span></strong></h3>
<p><a href="https://youtu.be/M4CD03oh0gw">https://youtu.be/M4CD03oh0gw</a></p>
<h3 class="s75CSd u60jwe r2fjmd AB4Wff" style="text-align: center;"><strong><span style="color: #000000;">Difference between local and global variables in javascript</span></strong></h3>
<h3><strong><span style="color: #000000;">Scope:</span></strong></h3>
<ul>
<li><span style="color: #000000;"><strong>Local Variables:</strong></span>
<ul>
<li><span style="color: #000000;">Local variables are declared within a specific block of code, typically within a function.</span></li>
<li><span style="color: #000000;">They are accessible only within the function or block in which they are defined.</span></li>
<li><span style="color: #000000;">Attempting to access a local variable from outside its scope will result in an error.</span></li>
</ul>
</li>
<li><span style="color: #000000;"><strong>Global Variables:</strong></span>
<ul>
<li><span style="color: #000000;">Global variables are declared outside of any function or block.</span></li>
<li><span style="color: #000000;">They are accessible from anywhere within the script, including inside functions.</span></li>
<li><span style="color: #000000;">Global variables have a global scope, meaning they can be accessed by any part of the code.</span></li>
</ul>
</li>
</ul>
<h3><strong><span style="color: #000000;">Accessibility:</span></strong></h3>
<ul>
<li><span style="color: #000000;"><strong>Local Variables:</strong></span>
<ul>
<li><span style="color: #000000;">Local variables are accessible only within the function or block in which they are declared.</span></li>
<li><span style="color: #000000;">They cannot be accessed from outside their containing function.</span></li>
</ul>
</li>
<li><span style="color: #000000;"><strong>Global Variables:</strong></span>
<ul>
<li><span style="color: #000000;">Global variables are accessible from anywhere within the script.</span></li>
<li><span style="color: #000000;">They can be accessed and modified from any part of the code, including inside functions.</span></li>
</ul>
</li>
</ul>
<h3><strong><span style="color: #000000;">Lifetime:</span></strong></h3>
<ul>
<li><span style="color: #000000;"><strong>Local Variables:</strong></span>
<ul>
<li><span style="color: #000000;">Local variables have a limited lifetime. They are created when the function in which they are declared is called, and they cease to exist once the function execution is complete.</span></li>
<li><span style="color: #000000;">Each time the function is called, a new instance of the local variable is created.</span></li>
</ul>
</li>
<li><span style="color: #000000;"><strong>Global Variables:</strong></span>
<ul>
<li><span style="color: #000000;">Global variables persist throughout the entire lifetime of the program.</span></li>
<li><span style="color: #000000;">They are initialized when the script starts executing and remain in memory until the script terminates or the page is refreshed.</span></li>
</ul>
</li>
</ul>
<p><span style="color: #000000;"><strong>Best Practices</strong></span></p>
<p><span style="color: #000000;">While both local and global variables have their use cases, it&#8217;s generally recommended to minimize the use of global variables whenever possible. Instead, opt for local variables, as they promote better encapsulation and reduce the likelihood of naming conflicts and unintended side effects. Additionally, using local variables can improve the performance of your code by limiting the scope of variables to only where they are needed.</span></p>
<p><span style="color: #000000;">When using global variables, exercise caution and ensure that their usage is justified. Avoid creating global variables unnecessarily, and consider alternative approaches such as passing values as function parameters or encapsulating related functionality within objects.</span></p>
<p><span style="color: #000000;">In conclusion, understanding the differences between local and global variables is crucial for writing clean, maintainable JavaScript code. By leveraging local variables within appropriate scopes and minimizing the use of global variables, you can write more robust and efficient code that is easier to understand and maintain.</span></p>
<p><strong><span style="color: #ff0000;">Also Check Our Latest Uploads Related to JavaScript</span></strong></p>
<p><a href="https://careersknowledge.in/javascript-functions-examples-for-practice/">javascript functions examples for practice</a></p>
<p><a href="https://careersknowledge.in/javascript-break-and-continue-examples/">JavaScript Break and Continue (Examples)</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://careersknowledge.in/local-and-global-variables-in-javascript/">Local and Global Variables in JavaScript</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/local-and-global-variables-in-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>javascript functions examples for practice</title>
		<link>https://careersknowledge.in/javascript-functions-examples-for-practice/</link>
					<comments>https://careersknowledge.in/javascript-functions-examples-for-practice/#respond</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Fri, 12 Apr 2024 14:06:56 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[arrow function in javascript]]></category>
		<category><![CDATA[javascript built-in functions]]></category>
		<category><![CDATA[javascript function example]]></category>
		<category><![CDATA[javascript functions]]></category>
		<category><![CDATA[types of functions in javascript]]></category>
		<category><![CDATA[types of functions in javascript with example]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1540</guid>

					<description><![CDATA[<p>javascript functions examples for practice If you are searching JavaScript functions examples for practice than you are on right place. In the expansive realm of web development, JavaScript functions stand as the cornerstone of interactive and dynamic web pages. From simple tasks like validating forms to complex operations like data manipulation and animation, functions empower ... <a title="javascript functions examples for practice" class="read-more" href="https://careersknowledge.in/javascript-functions-examples-for-practice/" aria-label="Read more about javascript functions examples for practice">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/javascript-functions-examples-for-practice/">javascript functions examples for practice</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1 style="text-align: center;"><strong><span style="color: #000000;">javascript functions examples for practice</span></strong></h1>
<p><span style="color: #000000;">If you are searching JavaScript functions examples for practice than you are on right place.</span></p>
<p><span style="color: #000000;">In the expansive realm of web development, JavaScript functions stand as the cornerstone of interactive and dynamic web pages. From simple tasks like validating forms to complex operations like data manipulation and animation, functions empower developers to create robust and responsive web applications. In this article, we delve into the fundamentals of JavaScript functions, exploring their syntax, usage, and importance in modern web development. </span></p>
<h3><span style="color: #000000;"><strong>Understanding Functions in JavaScript</strong></span></h3>
<p><span style="color: #000000;">At its core, a function in JavaScript is a block of reusable code designed to perform a specific task. Functions encapsulate a set of instructions, allowing developers to execute them multiple times without rewriting the same code. They promote code reusability, readability, and maintainability, making it easier to manage complex applications.</span></p>
<p><span style="color: #000000;"><strong>Syntax of JavaScript Functions</strong></span></p>
<p><span style="color: #000000;">The syntax of declaring a function in JavaScript is straightforward:</span></p>
<div class="dark bg-gray-950 rounded-md">
<div class="p-4 overflow-y-auto"><span style="color: #ff0000;"><strong><code class="!whitespace-pre hljs language-javascript"><span class="hljs-keyword" style="color: #ff0000;">function </span><span class="hljs-title function_" style="color: #ff0000;">functionName</span>(<span class="hljs-params" style="color: #ff0000;">parameters</span>)</code></strong></span></div>
<div class="p-4 overflow-y-auto"><span style="color: #ff0000;"><strong><code class="!whitespace-pre hljs language-javascript"> {<br />
</code></strong></span></div>
<div class="p-4 overflow-y-auto"><span style="color: #ff0000;"><strong><code class="!whitespace-pre hljs language-javascript">  <span class="hljs-comment">// <span style="color: #ff0000;">Function</span> <span style="color: #ff0000;">body</span></span><br />
</code></strong></span></div>
<div class="p-4 overflow-y-auto"><span style="color: #ff0000;"><strong><code class="!whitespace-pre hljs language-javascript">  <span class="hljs-comment">// <span style="color: #ff0000;">Code</span> <span style="color: #ff0000;">to</span> <span style="color: #ff0000;">be</span> <span style="color: #ff0000;">executed</span></span><br />
</code></strong></span></div>
<div class="p-4 overflow-y-auto"><span style="color: #ff0000;"><strong><code class="!whitespace-pre hljs language-javascript">}<br />
</code></strong></span></div>
</div>
<p><span style="color: #000000;">Here’s a breakdown of the components:</span></p>
<ul>
<li><span style="color: #000000;"><strong>function</strong>: Keyword indicating the start of a function declaration.</span></li>
<li><span style="color: #000000;"><strong>function Name</strong>: Identifier for the function, which is used to call it later.</span></li>
<li><span style="color: #000000;"><strong>parameters</strong>: Optional inputs that the function can accept. They are placeholders for values that the function will use.</span></li>
<li><span style="color: #000000;"><strong>Function body</strong>: The block of code enclosed within curly braces <code>{}</code>. It contains the instructions that define what the function does.</span></li>
</ul>
<h3><span style="color: #000000;"><strong>Types of Functions</strong></span></h3>
<p><span style="color: #000000;">JavaScript functions can be categorized into several types based on their usage:</span></p>
<ol>
<li><span style="color: #000000;"><strong>Named Functions</strong>: Functions with a specified name, as shown in the example above.</span></li>
<li><span style="color: #000000;"><strong>Anonymous Functions</strong>: Functions without a name. They are often assigned to variables or passed as arguments to other functions.</span></li>
<li><span style="color: #000000;"><strong>Arrow Functions</strong>: Introduced in ES6, arrow functions provide a concise syntax for writing functions.</span></li>
</ol>
<p><span style="color: #000000;"><strong>Function Invocation</strong></span></p>
<p><span style="color: #000000;">Functions are invoked (or called) using their name followed by parentheses <code>()</code>, optionally containing any required parameters.</span></p>
<p><span style="color: #000000;">function add(a, b) {</span><br />
<span style="color: #000000;">return a + b;</span><br />
<span style="color: #000000;">}</span></p>
<p><span style="color: #000000;">document.write((add(2, 3)); // Output: 5</span></p>
<p><span style="color: #000000;"><strong>Returning Values</strong></span></p>
<p><span style="color: #000000;">Functions can return values using the <code>return</code> statement. If no return value is specified, the function returns <code>undefined</code> by default.</span></p>
<p><span style="color: #000000;">function multiply(a, b) {</span><br />
<span style="color: #000000;">return a * b;</span><br />
<span style="color: #000000;">}</span></p>
<p><span style="color: #000000;">document.write(multiply(2, 3)); // Output: 6</span></p>
<p><strong><span style="color: #ff0000;">Example-1 WAP in javascript function when user click on the button then display a simple message.</span></strong></p>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script&gt;<br />
function MyAlert()<br />
{<br />
alert(&#8220;Welcome in javascript functions..&#8221;);<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;h2&gt;Click the button to display the alert message..&lt;/h2&gt;<br />
&lt;button onclick=&#8221;MyAlert()&#8221;&gt; Click Me&lt;/button&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p><img decoding="async" class="aligncenter size-full wp-image-1541" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptfunction.png" alt="" width="877" height="164" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptfunction.png 877w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptfunction-324x61.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptfunction-300x56.png 300w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptfunction-768x144.png 768w" sizes="(max-width: 877px) 100vw, 877px" /></p>
<p><span style="color: #ff0000;"><strong>When user click om the button then you will get the message</strong></span></p>
<p><img decoding="async" class="aligncenter size-large wp-image-1542" src="http://careersknowledge.in/wp-content/uploads/2024/04/function-1024x190.jpg" alt="" width="1024" height="190" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/function-1024x190.jpg 1024w, https://careersknowledge.in/wp-content/uploads/2024/04/function-324x60.jpg 324w, https://careersknowledge.in/wp-content/uploads/2024/04/function-300x56.jpg 300w, https://careersknowledge.in/wp-content/uploads/2024/04/function-768x142.jpg 768w, https://careersknowledge.in/wp-content/uploads/2024/04/function.jpg 1046w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p>For Live Class Watch Our Video on Youtube by click on the below link</p>
<p><a href="https://youtu.be/mKeexXmuDu8">https://youtu.be/mKeexXmuDu8</a></p>
<p><strong><span style="color: #ff0000;">Example-2 Write a javascript functions that perform all arithmetic operations like addition,subtraction,multiplication and division.</span></strong></p>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script&gt;<br />
function add()<br />
{<br />
var a=parseInt(prompt(&#8220;Enter the value of a&#8221;));<br />
var b=parseInt(prompt(&#8220;Enter the value of b&#8221;));<br />
c=a+b<br />
document.write(&#8220;Addition=&#8221;+c);<br />
}<br />
function sub()<br />
{<br />
var a=parseInt(prompt(&#8220;Enter the value of a&#8221;));<br />
var b=parseInt(prompt(&#8220;Enter the value of b&#8221;));<br />
c=a-b<br />
document.write(&#8220;Subtraction=&#8221;+c);<br />
}<br />
function multi()<br />
{<br />
var a=parseInt(prompt(&#8220;Enter the value of a&#8221;));<br />
var b=parseInt(prompt(&#8220;Enter the value of b&#8221;));<br />
c=a*b<br />
document.write(&#8220;Multiplication=&#8221;+c);<br />
}<br />
function div()<br />
{<br />
var a=parseInt(prompt(&#8220;Enter the value of a&#8221;));<br />
var b=parseInt(prompt(&#8220;Enter the value of b&#8221;));<br />
c=a/b<br />
document.write(&#8220;Division=&#8221;+c);<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;h2&gt;Click the button to perform Arithmetic operations..&lt;/h2&gt;<br />
&lt;button onclick=&#8221;add()&#8221;&gt;Addition&lt;/button&gt;<br />
&lt;button onclick=&#8221;sub()&#8221;&gt;Subtraction&lt;/button&gt;&lt;br&gt;<br />
&lt;button onclick=&#8221;multi()&#8221;&gt;Multiplication&lt;/button&gt;<br />
&lt;button onclick=&#8221;div()&#8221;&gt;Division&lt;/button&gt;&lt;br&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1543" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-1024x237.jpg" alt="" width="1024" height="237" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-1024x237.jpg 1024w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-324x75.jpg 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-300x69.jpg 300w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-768x178.jpg 768w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples.jpg 1228w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>when you click on addition button then you will below output</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1544" src="http://careersknowledge.in/wp-content/uploads/2024/04/function-1024x210.png" alt="" width="1024" height="210" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/function-1024x210.png 1024w, https://careersknowledge.in/wp-content/uploads/2024/04/function-324x66.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/function-300x62.png 300w, https://careersknowledge.in/wp-content/uploads/2024/04/function-768x157.png 768w, https://careersknowledge.in/wp-content/uploads/2024/04/function.png 1107w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1546 size-large" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-1-1024x253.jpg" alt="javascript functions examples for practice" width="1024" height="253" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-1-1024x253.jpg 1024w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-1-324x80.jpg 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-1-300x74.jpg 300w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-1-768x189.jpg 768w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-functions-examples-1.jpg 1208w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>After providing the value of b than you will get the addition.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1547 size-large" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascript-examples-1024x169.jpg" alt="javascript functions examples for practice" width="1024" height="169" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascript-examples-1024x169.jpg 1024w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-examples-324x53.jpg 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-examples-300x49.jpg 300w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-examples-768x127.jpg 768w, https://careersknowledge.in/wp-content/uploads/2024/04/javascript-examples.jpg 1073w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p><span style="color: #000000;">Similarly you can click on others button then you will get the result of subtraction,multiplication and division.</span></p>
<p><strong><span style="color: #ff0000;">Example-3 Write a javascript function using return statement.</span></strong></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;head&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">function MyReturn()</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">return &#8220;welcome in return statement&#8230;.&#8221;;</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/head&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">document.write(MyReturn());</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Example-4 </strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;head&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">function MyProduct(x,y,z)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">return x*y*z;</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/head&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">document.write(&#8220;The Product:&#8221;+MyProduct(2,4,5)+&#8221;&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">document.write(&#8220;The Product:&#8221;+MyProduct(12,4,5)+&#8221;&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">document.write(&#8220;The Product:&#8221;+MyProduct(7,4,5)+&#8221;&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;">The Product: 40</span></p>
<p><span style="color: #000000;">The Product: 240</span></p>
<p><span style="color: #000000;">The Product: 140</span></p>
<p><span style="color: #ff0000;"><strong>Example-5 Write a javascript function to find maximum value between two numbers.</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;head&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">function max(x,y)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">if (x&gt;y)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">return x;</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">else</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">return y;</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/head&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">document.write(&#8220;Maximum Value:&#8221;+max(2,4)+&#8221;&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">document.write(&#8220;Maximum Value:&#8221;+max(12,40)+&#8221;&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;">Maximum Value:4</span><br />
<span style="color: #000000;">Maximum Value:40</span></p>
<p><span style="color: #000000;"><strong>Conclusion</strong></span></p>
<p><span style="color: #000000;">JavaScript functions play a vital role in web development, offering a powerful mechanism for organizing and executing code. By encapsulating logic into reusable blocks, functions enhance code modularity, readability, and maintainability. Whether it’s handling user interactions, processing data, or creating dynamic content, mastering JavaScript functions is essential for every web developer. So, embrace the versatility of functions and unlock the full potential of JavaScript in your projects.</span></p>
<p><strong><span style="color: #ff0000;">Also Check Our Latest Uploads</span></strong></p>
<p><a href="https://careersknowledge.in/javascript-break-and-continue-examples/">JavaScript Break and Continue (Examples)</a></p>
<p><a href="https://careersknowledge.in/javascript-looping-statements-with-examples/">JavaScript looping statements with examples</a></p>
<p>The post <a href="https://careersknowledge.in/javascript-functions-examples-for-practice/">javascript functions examples for practice</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/javascript-functions-examples-for-practice/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaScript Break and Continue (Examples)</title>
		<link>https://careersknowledge.in/javascript-break-and-continue-examples/</link>
					<comments>https://careersknowledge.in/javascript-break-and-continue-examples/#comments</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Thu, 11 Apr 2024 09:04:33 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[break statement in javascript example break in foreach javascript break for loop javascript]]></category>
		<category><![CDATA[continue in for loop javascript]]></category>
		<category><![CDATA[continue statement in javascript]]></category>
		<category><![CDATA[javascript break if]]></category>
		<category><![CDATA[javascript break statement]]></category>
		<category><![CDATA[javascript continue statement]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1534</guid>

					<description><![CDATA[<p>JavaScript Break and Continue (Examples) JavaScript, as a versatile and powerful programming language, offers developers a plethora of tools to efficiently manipulate data and control program flow. Among these tools, the break and continue statements stand out as indispensable tools for managing loops. In this article, we&#8217;ll delve into the functionality and usage of these ... <a title="JavaScript Break and Continue (Examples)" class="read-more" href="https://careersknowledge.in/javascript-break-and-continue-examples/" aria-label="Read more about JavaScript Break and Continue (Examples)">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/javascript-break-and-continue-examples/">JavaScript Break and Continue (Examples)</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1 style="text-align: center;"><span style="color: #000000;">JavaScript Break and Continue (Examples)</span></h1>
<p><span style="color: #000000;">JavaScript, as a versatile and powerful programming language, offers developers a plethora of tools to efficiently manipulate data and control program flow. Among these tools, the <strong>break</strong> and <strong>continue</strong> statements stand out as indispensable tools for managing loops. In this article, we&#8217;ll delve into the functionality and usage of these statements, exploring how they can enhance the efficiency and readability of your code. In this blog we will learn JavaScript Break and Continue (Examples).</span></p>
<p><span style="color: #000000;"><strong>Understanding the Break Statement</strong></span></p>
<p><span style="color: #000000;">The <strong>break</strong> statement in JavaScript serves a simple yet crucial purpose: it allows you to abruptly exit a loop structure, be it a <strong>for</strong>, <strong>while</strong>, or <strong>do-while</strong> loop. When encountered within the body of a loop, the <strong>break</strong> statement immediately terminates the loop&#8217;s execution and transfers control to the statement following the loop.</span></p>
<p><span style="color: #000000;">In others word It breaks the iteration of a loop at a specific condition</span></p>
<p><span style="color: #000000;">Syntax- break;</span></p>
<p><span style="color: #ff0000;"><strong>Example-1 WAP to terminate the loop when i value become 6.</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span></p>
<p><span style="color: #000000;">&lt;script&gt;</span></p>
<p><span style="color: #000000;">for (i=1;i&lt;=10;i++ )</span></p>
<p><span style="color: #000000;">{</span></p>
<p><span style="color: #000000;">            if (i==6)</span></p>
<p><span style="color: #000000;">            {</span></p>
<p><span style="color: #000000;">                  break;</span></p>
<p><span style="color: #000000;">            }</span></p>
<p><span style="color: #000000;">            document.write(&#8220;&lt;br&gt;&#8221;+i);</span></p>
<p><span style="color: #000000;">}</span></p>
<p><span style="color: #000000;">&lt;/script&gt;</span></p>
<p><span style="color: #000000;">&lt;/html&gt;</span></p>
<p><strong><span style="color: #ff0000;">Output</span></strong></p>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p><span style="color: #ff0000;"><strong>Example-2 WAP to print area of circle 3 times loop terminate when user enter radius as 0</strong></span></p>
<div><span style="color: #000000;">&lt;html&gt;</span></div>
<div><span style="color: #000000;">&lt;script&gt;</span></div>
<div><span style="color: #000000;">for (i=1;i&lt;=3;i++ )</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">var r=parseInt(prompt(&#8220;enter the radius&#8221;));</span></div>
<div></div>
<div><span style="color: #000000;">if (r==0)</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">document.write(&#8220;&lt;br&gt;loop terminated by break statement..&#8221;);</span></div>
<div><span style="color: #000000;">break</span></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">var area=3.14*r*r;</span></div>
<div><span style="color: #000000;">document.write(&#8220;&lt;br&gt;Area of circle=&#8221;+area);</span></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">&lt;/script&gt;</span></div>
<div><span style="color: #000000;">&lt;/html&gt;</span></div>
<div></div>
<div><span style="color: #000000;">In the above example if we do not enter r value 0 than you will get 3 times area of circle but if you enter r value 0 then loop terminate and you got the message &#8220;Loop terminated by break statement..&#8221;. If you enter first time value of r=5 and second time value of r=0 then you will get the below output-</span></div>
<div></div>
<div><span style="color: #ff0000;"><strong>Output</strong></span></div>
<div><span style="color: #000000;">Area of Circle=78.5</span></div>
<div><span style="color: #000000;">Loop terminated by break statement..</span></div>
<div></div>
<div><span style="color: #ff0000;"><strong>Watch Our Live class Video on YouTube by click on the below link</strong></span></div>
<div><a href="https://youtu.be/nwUjrCybH9g">https://youtu.be/nwUjrCybH9g</a></div>
<p>&nbsp;</p>
<p><span style="color: #000000;"><strong>Utilizing the Continue Statement</strong></span></p>
<p><span style="color: #000000;">While the <strong>break</strong> statement allows for premature termination of a loop, the <strong>continue</strong> statement provides a means to skip the current iteration and proceed to the next one. When encountered within the body of a loop, the <strong>continue</strong> statement effectively bypasses the remaining code within the loop&#8217;s body for the current iteration and moves on to the next iteration.</span></p>
<div><span style="color: #ff0000;"><strong>Example-1 </strong></span></div>
<div><span style="color: #000000;">&lt;html&gt;</span></div>
<div><span style="color: #000000;">&lt;script&gt;</span></div>
<div><span style="color: #000000;">for (i=1;i&lt;=10;i++ )</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">if (i==6)</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">continue;</span></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">document.write(&#8220;&lt;br&gt;&#8221;+i);</span></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">&lt;/script&gt;</span></div>
<div><span style="color: #000000;">&lt;/html&gt;</span></div>
<div></div>
<div><span style="color: #ff0000;"><strong>Output</strong></span></div>
<div><span style="color: #000000;">1</span></div>
<div><span style="color: #000000;">2</span></div>
<div><span style="color: #000000;">3</span></div>
<div><span style="color: #000000;">4</span></div>
<div><span style="color: #000000;">5</span></div>
<div><span style="color: #000000;">7</span></div>
<div><span style="color: #000000;">8</span></div>
<div><span style="color: #000000;">9</span></div>
<div><span style="color: #000000;">10</span></div>
<div><span style="color: #0000ff;"><strong>Note-6 skip in the iteration</strong></span></div>
<p><span style="color: #ff0000;"><strong>Example-2 WAP to print area of circle 5 times loop terminate when user enter radius as 0 and skip the iterate when user enter negative value.</strong></span></p>
<div><span style="color: #000000;">&lt;html&gt;</span></div>
<div><span style="color: #000000;">&lt;script&gt;</span></div>
<div><span style="color: #000000;">for (i=1;i&lt;=5;i++ )</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">var r=parseInt(prompt(&#8220;enter the radius&#8221;));</span></div>
<div></div>
<div><span style="color: #000000;">if (r==0)</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">document.write(&#8220;&lt;br&gt;loop terminated by break statement..&#8221;);</span></div>
<div><span style="color: #000000;">break;</span></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">if (r&lt;0)</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">continue;</span></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">var area=3.14*r*r;</span></div>
<div><span style="color: #000000;">document.write(&#8220;&lt;br&gt;Area of circle=&#8221;+area);</span></div>
<div></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">&lt;/script&gt;</span></div>
<div><span style="color: #000000;">&lt;/html&gt;</span></div>
<div></div>
<div><span style="color: #ff0000;"><strong>Example-3 WAP to print the sum of only the positive number.</strong></span></div>
<div><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var sum=0</span><br />
<span style="color: #000000;">for (i=1;i&lt;=10;i++ )</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">var n=parseInt(prompt(&#8220;enter the number&#8221;));</span><br />
<span style="color: #000000;">if (n&lt;0)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">continue;</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">sum=sum+n;</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">document.write(&#8220;Sum of the positive number=&#8221;+sum);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></div>
<div></div>
<p><span style="color: #000000;"><strong>Practical Applications</strong></span></p>
<p><span style="color: #000000;">Both the <strong>break</strong> and <strong>continue</strong> statements find numerous practical applications in JavaScript programming. Here are a few common scenarios where they can be particularly useful:</span></p>
<p><span style="color: #000000;"><strong>Searching within Arrays:</strong> When iterating over an array, the <strong>break</strong> statement can be used to exit the loop once a desired condition is met, while the <strong>continue</strong> statement can be employed to skip certain elements based on specific criteria.</span></p>
<p><span style="color: #000000;"><strong>Validating Input:</strong> In scenarios where user input needs to be validated, these statements can be used to efficiently handle edge cases or invalid inputs without executing unnecessary code.</span></p>
<p><span style="color: #000000;"><strong>Optimizing Loops:</strong> By strategically placing <strong>break</strong> and <strong>continue</strong> statements within loops, you can improve the efficiency of your code and minimize unnecessary iterations.</span></p>
<p><span style="color: #000000;"><strong>Conclusion</strong></span></p>
<p><span style="color: #000000;">In conclusion, the <strong>break</strong> and <strong>continue</strong> statements are powerful tools in JavaScript for controlling the flow of loops. Whether you need to prematurely exit a loop or skip certain iterations, these statements provide essential mechanisms for achieving such behavior. By mastering their usage, you can write more efficient and readable code, enhancing the overall quality of your JavaScript applications.</span></p>
<p><strong><span style="color: #ff0000;">Also Check Our Latest Uploads</span></strong></p>
<p><a href="https://careersknowledge.in/javascript-looping-statements-with-examples/">JavaScript looping statements with examples</a></p>
<p><a href="https://careersknowledge.in/types-of-conditional-statements-in-javascript/">types of conditional statements in javascript</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://careersknowledge.in/javascript-break-and-continue-examples/">JavaScript Break and Continue (Examples)</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/javascript-break-and-continue-examples/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>JavaScript looping statements with examples</title>
		<link>https://careersknowledge.in/javascript-looping-statements-with-examples/</link>
					<comments>https://careersknowledge.in/javascript-looping-statements-with-examples/#comments</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Mon, 08 Apr 2024 14:32:55 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[do while loop in javascript]]></category>
		<category><![CDATA[for loop example]]></category>
		<category><![CDATA[for loop in javascript]]></category>
		<category><![CDATA[for loop java]]></category>
		<category><![CDATA[for loop with examples]]></category>
		<category><![CDATA[javascript do while loop]]></category>
		<category><![CDATA[types of loops in javascript]]></category>
		<category><![CDATA[while loop in javascript]]></category>
		<category><![CDATA[while loop with examples]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1518</guid>

					<description><![CDATA[<p>JavaScript Looping Statements: Examples and Applications In the world of programming, repetition is a common necessity. Whether it&#8217;s iterating through arrays, processing data, or executing tasks until a condition is met, looping statements play a crucial role in automating tasks and streamlining code. In this article, we&#8217;ll dive deep into JavaScript looping statements with examples, ... <a title="JavaScript looping statements with examples" class="read-more" href="https://careersknowledge.in/javascript-looping-statements-with-examples/" aria-label="Read more about JavaScript looping statements with examples">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/javascript-looping-statements-with-examples/">JavaScript looping statements with examples</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="text-align: center;"><span style="color: #000000;"><strong>JavaScript Looping Statements: Examples and Applications</strong></span></p>
<p><span style="color: #000000;">In the world of programming, repetition is a common necessity. Whether it&#8217;s iterating through arrays, processing data, or executing tasks until a condition is met, looping statements play a crucial role in automating tasks and streamlining code. In this article, we&#8217;ll dive deep into JavaScript looping statements with examples, exploring their syntax, examples, and practical applications in web development.</span></p>
<p><span style="color: #000000;"><strong>Understanding JavaScript Looping Statements:</strong></span></p>
<p><span style="color: #000000;">JavaScript offers several types of looping statements, each tailored to specific use cases:</span></p>
<ol>
<li><span style="color: #000000;"><strong>for Loop:</strong> The <strong>for</strong> loop is one of the most commonly used looping statements in JavaScript. It iterates over a block of code a specified number of times, with each iteration controlled by a loop counter or index variable.</span></li>
</ol>
<p><span style="color: #000000;">Syntax-</span></p>
<p><span style="color: #000000;">            for(initialization;condition;increment/decrement)</span></p>
<p><span style="color: #000000;">             {</span></p>
<p><span style="color: #000000;">              Statements</span></p>
<p><span style="color: #000000;">              }</span></p>
<p><span style="color: #ff0000;"><strong>Example-1 WAP to print welcome msg 10 times.</strong></span></p>
<p>&lt;html&gt;<br />
&lt;script&gt;<br />
for (i=1;i&lt;=5;i++ )//i=i+1=2+1=3+1=4+1=5+1=6<br />
{<br />
document.write(&#8220;&lt;br&gt;Welcome in javascript loop statement&#8230;&#8221;);<br />
}</p>
<p>&lt;/script&gt;<br />
&lt;/html&gt;</p>
<p><span style="color: #ff0000;"><strong>Example-2 WAP to print 1 to 10 number</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span></p>
<p><span style="color: #000000;">for (i=1;i&lt;=20;i++ )</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;&#8221;+i);</span><br />
<span style="color: #000000;">}</span></p>
<p><span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><strong><span style="color: #ff0000;">Example-3 WAP to print odd numbers between 1 to 20 number</span></strong></p>
<div>&lt;html&gt;</div>
<div>&lt;script&gt;</div>
<div>for (i=1;i&lt;=20;i++ )//i=1+2=3+2=5&#8230;21</div>
<div>{</div>
<div>if (i%2!=0)</div>
<div>{</div>
<div>document.write(&#8220;&lt;br&gt;&#8221;+i);</div>
<div>}</div>
<div>}</div>
<div>&lt;/script&gt;</div>
<div>&lt;/html&gt;</div>
<div></div>
<div><span style="color: #ff0000;"><strong>Example-4 WAP to print even and odd numbers between 1 to 30 number</strong></span></div>
<div><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">for (i=1;i&lt;=30;i++)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">if (i%2==0)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Even=&#8221;+i);</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">else</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Odd=&#8221;+i);</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></div>
<div></div>
<div><span style="color: #ff0000;"><strong>Example-5  WAP to print table of any number.</strong></span></div>
<div>
<div>&lt;html&gt;</div>
<div>&lt;script&gt;</div>
<div>var n=parseInt(prompt(&#8220;Enter any number&#8230;&#8221;))</div>
<div>for (i=1;i&lt;=10;i++ )</div>
<div>{</div>
<div>table=n*i;</div>
<div>document.write(&#8220;&lt;br&gt;&#8221;+n+&#8221;*&#8221;+i+&#8221;=&#8221;+table);</div>
<div></div>
<div>}</div>
<div>&lt;/script&gt;</div>
<div>&lt;/html&gt;</div>
<div></div>
<div><span style="color: #ff0000;"><strong>Example-6 WAP to print number and its square and cube value up to 10.</strong></span></div>
<div>
<div><span style="color: #000000;">&lt;html&gt;</span></div>
<div><span style="color: #000000;">&lt;script&gt;</span></div>
<div><span style="color: #000000;">for (i=1;i&lt;=10;i++ )</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">document.write(&#8220;&lt;br&gt;Number=&#8221;+i);</span></div>
<div><span style="color: #000000;">document.write(&#8220;&lt;br&gt;Square=&#8221;+i*i);</span></div>
<div><span style="color: #000000;">document.write(&#8220;&lt;br&gt;Cube=&#8221;+i*i*i);</span></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">&lt;/script&gt;</span></div>
<div><span style="color: #000000;">&lt;/html&gt;</span></div>
</div>
<div></div>
<div><strong><span style="color: #ff0000;">For Live Class Watch Our Video on YouTube by click on the below link</span></strong></div>
<div> <a href="https://youtu.be/t1uTvYznoY0">https://youtu.be/t1uTvYznoY0</a></div>
<div>
<div></div>
</div>
</div>
<ol start="2">
<li><span style="color: #000000;"><strong>while Loop:</strong> The <strong>while</strong> loop executes a block of code as long as a specified condition is true. Unlike the <strong>for</strong> loop, which requires an explicit initialization and incrementing of a loop counter, the <strong>while</strong> loop relies solely on the condition to determine when to terminate.</span></li>
</ol>
<p><span style="color: #000000;">Syntax-</span></p>
<p><span style="color: #000000;">               Initialization;</span></p>
<p><span style="color: #000000;">            while (&lt;condition&gt;)</span></p>
<p><span style="color: #000000;">              {</span></p>
<p><span style="color: #000000;">                        Statement;</span></p>
<p><span style="color: #000000;">                        Increment/decrement;</span></p>
<p><span style="color: #000000;">              }</span></p>
<p><span style="color: #ff0000;"><strong>Example-1 WAP to print 1 to 10 number.</strong></span></p>
<p><span style="color: #ff0000;"><span style="color: #000000;">&lt;html&gt;<br />
&lt;script&gt;<br />
i=1;<br />
while(i&lt;=10)<br />
{<br />
document.write(i+&#8221;&lt;br&gt;&#8221;);<br />
i++;<br />
}<br />
&lt;/script&gt;<br />
&lt;/html&gt;</span> </span></p>
<p><strong><span style="color: #ff0000;">Example-2 WAP to print odd numbers 1 to 20 number</span></strong></p>
<div><span style="color: #000000;">&lt;html&gt;</span></div>
<div><span style="color: #000000;">&lt;script&gt;</span></div>
<div><span style="color: #000000;">i=1;</span></div>
<div><span style="color: #000000;">while (i&lt;=20)</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">document.write(i+&#8221;&lt;br&gt;&#8221;);</span></div>
<div><span style="color: #000000;">i=i+2;</span></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">&lt;/script&gt;</span></div>
<div><span style="color: #000000;">&lt;/html&gt;</span></div>
<div><span style="color: #ff0000;"><strong>Example-3 WAP to print table of any number</strong></span></div>
<div><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var num=parseInt(prompt(&#8220;Enter any number&#8221;))</span><br />
<span style="color: #000000;">i=1;</span><br />
<span style="color: #000000;">while (i&lt;=10)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">t=num*i;</span><br />
<span style="color: #000000;">document.write(t+&#8221;&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">i++;</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></div>
<div></div>
<div><span style="color: #ff0000;"><strong>Example-4 WAP to find sum of the following series 1+2+3+4+5+&#8230;.10=55</strong></span></div>
<div><span style="color: #000000;">&lt;html&gt;<br />
&lt;script&gt;<br />
var sum=0;//1//3//6//10//15//21//28//36//45//55<br />
i=1;<br />
while (i&lt;=10)<br />
{<br />
sum=sum+i;//6+4=10+5=15+6=21+7=28+8=36+9=45+10=55<br />
i++;<br />
}<br />
document.write(&#8220;Sum of the series=&#8221;+sum);<br />
&lt;/script&gt;<br />
&lt;/html&gt;</span></div>
<div></div>
<div><span style="color: #ff0000;"><strong>Example-5 WAP to find sum of the following series 1+3+5+9&#8230;.19=100</strong></span></div>
<div></div>
<div>
<div><span style="color: #000000;">&lt;html&gt;</span></div>
<div><span style="color: #000000;">&lt;script&gt;</span></div>
<div><span style="color: #000000;">var sum=0;</span></div>
<div><span style="color: #000000;">i=1;</span></div>
<div><span style="color: #000000;">while (i&lt;=19)</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">sum=sum+i;</span></div>
<div><span style="color: #000000;">i=i+2;</span></div>
<div><span style="color: #000000;">}</span></div>
<div><span style="color: #000000;">document.write(&#8220;Sum of the series=&#8221;+sum);</span></div>
<div><span style="color: #000000;">&lt;/script&gt;</span></div>
<div><span style="color: #000000;">&lt;/html&gt;</span></div>
</div>
<div></div>
<div><span style="color: #ff0000;"><strong>For Live Class watch our full video on YouTube by click on the below link</strong></span></div>
<div><a href="https://youtu.be/kH4Q2zjS8xw">https://youtu.be/kH4Q2zjS8xw</a></div>
<ol start="3">
<li><span style="color: #000000;"><strong>do while Loop:</strong> Similar to the <strong>while</strong> loop, the <strong>do&#8230;while</strong> loop executes a block of code as long as a specified condition is true. However, the <strong>do&#8230;while</strong> loop guarantees that the block of code is executed at least once before checking the condition for subsequent iterations.</span></li>
</ol>
<p><span style="color: #000000;">Syntax-</span></p>
<p><span style="color: #000000;">                initialization;</span></p>
<p><span style="color: #000000;">               do</span></p>
<p><span style="color: #000000;">               {</span></p>
<p><span style="color: #000000;">               Statement;</span></p>
<p><span style="color: #000000;">               } while (condition);</span></p>
<p><strong><span style="color: #ff0000;">Example-1 WAP to print odd numbers 1 to 20 number</span></strong></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">i=1;</span><br />
<span style="color: #000000;">do</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(i+&#8221;&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">i=i+2;</span><br />
<span style="color: #000000;">}while (i&lt;=20);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Example-2 WAP to find sum of the following series 1+4+9+16&#8230;.100=385</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var sum=0;//1//5//14</span><br />
<span style="color: #000000;">i=1;</span><br />
<span style="color: #000000;">do</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">sum=sum+i*i;//0+1=1+4=5+9=14</span><br />
<span style="color: #000000;">i++;</span><br />
<span style="color: #000000;">}while (i&lt;=10);</span><br />
<span style="color: #000000;">document.write(&#8220;Sum of the series=&#8221;+sum);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><strong><span style="color: #ff0000;">Example-2 WAP to print number and its square value depending on user range.</span></strong></p>
<div><span style="color: #000000;">&lt;html&gt;</span></div>
<div><span style="color: #000000;">&lt;script&gt;</span></div>
<div><span style="color: #000000;">var start=parseInt(prompt(&#8220;Enter start range&#8230;&#8221;))</span></div>
<div><span style="color: #000000;">var end=parseInt(prompt(&#8220;Enter ending range&#8230;&#8221;))</span></div>
<div><span style="color: #000000;">var i=start;</span></div>
<div><span style="color: #000000;">do</span></div>
<div><span style="color: #000000;">{</span></div>
<div><span style="color: #000000;">document.write(&#8220;Number=&#8221;+i+&#8221;&lt;br&gt;&#8221;);</span></div>
<div><span style="color: #000000;">document.write(&#8220;Square value=&#8221;+i*i+&#8221;&lt;br&gt;&#8221;);</span></div>
<div><span style="color: #000000;">i++;</span></div>
<div><span style="color: #000000;">}while(i&lt;=end);</span></div>
<div><span style="color: #000000;">&lt;/script&gt;</span></div>
<div><span style="color: #000000;">&lt;/html&gt;</span></div>
<p><span style="color: #000000;"><strong>Practical Applications of JavaScript Looping Statements:</strong></span></p>
<p><span style="color: #000000;">JavaScript looping statements find wide-ranging applications in web development:</span></p>
<ol>
<li><span style="color: #000000;"><strong>Iterating Through Arrays:</strong> Looping statements are commonly used to iterate through arrays, allowing developers to access and process each element individually.</span></li>
<li><span style="color: #000000;"><strong>Generating HTML Elements:</strong> Looping statements can be used to dynamically generate HTML elements based on data from arrays or other sources, enabling the creation of dynamic web content.</span></li>
<li><span style="color: #000000;"><strong>Handling User Input:</strong> Looping statements are useful for validating and processing user input from forms, ensuring that data is handled appropriately and errors are caught.</span></li>
<li><span style="color: #000000;"><strong>Animating Elements:</strong> By utilizing looping statements in conjunction with CSS transitions or JavaScript animation libraries, developers can create dynamic and interactive animations on web pages.</span></li>
</ol>
<p><span style="color: #000000;"><strong>Best Practices for Using JavaScript Looping Statements:</strong></span></p>
<p><span style="color: #000000;">To maximize the effectiveness and efficiency of JavaScript looping statements, consider the following best practices:</span></p>
<ol>
<li><span style="color: #000000;"><strong>Use the Appropriate Looping Statement:</strong> Choose the looping statement that best fits the specific requirements and conditions of your task.</span></li>
<li><span style="color: #000000;"><strong>Avoid Infinite Loops:</strong> Ensure that your looping statements have a clear termination condition to prevent infinite loops, which can cause the browser to become unresponsive.</span></li>
<li><span style="color: #000000;"><strong>Optimize Performance:</strong> Minimize unnecessary computations and operations within looping statements to improve code performance, especially when dealing with large datasets or complex algorithms.</span></li>
<li><span style="color: #000000;"><strong>Keep Code Readable:</strong> Use meaningful variable names and indentation to make your looping statements more readable and understandable for yourself and other developers.</span></li>
</ol>
<p><span style="color: #000000;"><strong>Conclusion:</strong></span></p>
<p><span style="color: #000000;">JavaScript looping statements are indispensable tools for automating repetitive tasks and iterating through data in web development. By mastering the syntax, examples, and practical applications of <strong>for</strong>, <strong>while</strong>, and <strong>do&#8230;while</strong> loops, developers can write more efficient, maintainable, and scalable code for a wide range of projects. Whether you&#8217;re a novice programmer or a seasoned developer, understanding and utilizing JavaScript looping statements effectively will undoubtedly enhance your coding skills and productivity in the dynamic world of web development.</span></p>
<p><strong><span style="color: #000000;">Also Check our latest upload</span></strong></p>
<p><a href="https://careersknowledge.in/javascript-operators-with-example/">JavaScript operators with example</a></p>
<p><a href="https://careersknowledge.in/javascript-programs-examples-with-output/">JavaScript programs examples with output</a></p>
<p>The post <a href="https://careersknowledge.in/javascript-looping-statements-with-examples/">JavaScript looping statements with examples</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/javascript-looping-statements-with-examples/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>types of conditional statements in javascript</title>
		<link>https://careersknowledge.in/types-of-conditional-statements-in-javascript/</link>
					<comments>https://careersknowledge.in/types-of-conditional-statements-in-javascript/#comments</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Fri, 05 Apr 2024 15:02:08 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[conditional statements in javascript with example]]></category>
		<category><![CDATA[if else statement]]></category>
		<category><![CDATA[if elseif statement with examples]]></category>
		<category><![CDATA[if statement]]></category>
		<category><![CDATA[javascript conditional statements exercises]]></category>
		<category><![CDATA[switch statement with example]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1515</guid>

					<description><![CDATA[<p>types of conditional statements in javascript Introduction: JavaScript, being a versatile and widely used programming language, offers several ways to control the flow of your code. Conditional statements are fundamental constructs in programming that allow you to execute different blocks of code based on certain conditions. In JavaScript, these conditional statements are crucial for creating ... <a title="types of conditional statements in javascript" class="read-more" href="https://careersknowledge.in/types-of-conditional-statements-in-javascript/" aria-label="Read more about types of conditional statements in javascript">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/types-of-conditional-statements-in-javascript/">types of conditional statements in javascript</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1 style="text-align: center;"><strong><span style="color: #000000;">types of conditional statements in javascript</span></strong></h1>
<p><span style="color: #000000;">Introduction: JavaScript, being a versatile and widely used programming language, offers several ways to control the flow of your code. Conditional statements are fundamental constructs in programming that allow you to execute different blocks of code based on certain conditions. In JavaScript, these conditional statements are crucial for creating dynamic and interactive web applications. In this article, we&#8217;ll delve into the various types of conditional statements in JavaScript along with practical examples to illustrate their usage.</span></p>
<p><span style="color: #000000;"><strong>1) if Statement:</strong> </span></p>
<p><span style="color: #000000;">The <strong>if</strong> statement is one of the most basic conditional statements in JavaScript. It allows you to execute a block of code if a specified condition evaluates to true.</span></p>
<p><span style="color: #000000;">Syntax-</span></p>
<p><span style="color: #000000;">if (condition)</span></p>
<p><span style="color: #000000;">{</span></p>
<p><span style="color: #000000;">Statement // true block</span></p>
<p><span style="color: #000000;">}</span></p>
<p><span style="color: #ff0000;"><strong>Example-1</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var x=prompt(&#8220;Enter any number&#8221;)</span><br />
<span style="color: #000000;">if (x&gt;20)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">alert(x+ &#8221; is greater than 20&#8243;);</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;">If we enter x value is 25 then you will get the following output</span></p>
<p><span style="color: #000000;">25 is greater than 20</span></p>
<p><span style="color: #000000;"><strong>2) if&#8230;else Statement:</strong> </span></p>
<p><span style="color: #000000;">The <strong>if&#8230;else</strong> statement extends the functionality of the <strong>if</strong> statement by providing an alternative block of code to execute when the condition is false.</span></p>
<p><span style="color: #000000;">Syntax-</span></p>
<p><span style="color: #000000;">if (condition)</span></p>
<p><span style="color: #000000;">{</span></p>
<p><span style="color: #000000;">Statement // true block</span></p>
<p><span style="color: #000000;">}</span></p>
<p><span style="color: #000000;">else</span></p>
<p><span style="color: #000000;">{</span></p>
<p><span style="color: #000000;">Statement // false block</span></p>
<p><span style="color: #000000;">}</span></p>
<p><span style="color: #ff0000;"><strong>Example-1</strong></span></p>
<p>&lt;html&gt;<br />
&lt;script&gt;<br />
var x=prompt(&#8220;Enter any number&#8221;)<br />
if (x&gt;20)<br />
{<br />
alert(x+ &#8221; is greater than 20&#8243;);<br />
}<br />
else<br />
{<br />
alert(x+ &#8221; is less than 20&#8243;);<br />
}</p>
<p>&lt;/script&gt;<br />
&lt;/html&gt;</p>
<p><strong><span style="color: #000000;">Output</span></strong></p>
<p><span style="color: #000000;">Enter any number-14</span></p>
<p><span style="color: #000000;">14 is less than 20</span></p>
<p><span style="color: #ff0000;"><strong>Example-2</strong></span></p>
<p>&lt;html&gt;<br />
&lt;script&gt;<br />
var a=parseInt(prompt(&#8220;enter the value of a&#8221;))<br />
var b=parseInt(prompt(&#8220;enter the value of b&#8221;))<br />
if (a&gt;b)<br />
{<br />
document.write(a+&#8221; is greater than &#8220;+b)<br />
}<br />
else<br />
{<br />
document.write(b+&#8221; is greater than &#8220;+a)<br />
}<br />
&lt;/script&gt;<br />
&lt;/html&gt;</p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p><strong><span style="color: #0000ff;">First Run</span></strong></p>
<p><span style="color: #000000;">Enter the value of a 40</span></p>
<p><span style="color: #000000;">Enter the value of b 25</span></p>
<p><span style="color: #000000;">40 is greater than 25</span></p>
<p><span style="color: #0000ff;"><strong>Second Run</strong></span></p>
<p><span style="color: #000000;">Enter the value of a 60</span></p>
<p><span style="color: #000000;">Enter the value of b 85</span></p>
<p><span style="color: #000000;">85  is greater than 60</span></p>
<p><strong><span style="color: #ff0000;">Example-3</span></strong></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var n=parseInt(prompt(&#8220;enter any number&#8221;))</span><br />
<span style="color: #000000;">if (n%2==0)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(n+&#8221; is even&#8221;)</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">else</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(n+&#8221; is odd&#8221;)</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p><strong><span style="color: #0000ff;">First Run-</span></strong></p>
<p>Enter any number 24</p>
<p>24 is even</p>
<p><strong><span style="color: #0000ff;">Second Run</span></strong></p>
<p>Enter any number 13</p>
<p>13 is odd</p>
<p><strong><span style="color: #000000;">3) if&#8230;else if&#8230;else Statement: </span></strong></p>
<p><span style="color: #000000;">This statement allows you to evaluate multiple conditions and execute different blocks of code accordingly.</span></p>
<p><span style="color: #000000;">if (condition 1)</span></p>
<p><span style="color: #000000;">{</span></p>
<p><span style="color: #000000;">Statement // true block</span></p>
<p><span style="color: #000000;">}</span></p>
<p><span style="color: #000000;">else if(condition 2)</span></p>
<p><span style="color: #000000;">{</span></p>
<p><span style="color: #000000;">Statement // true block</span></p>
<p><span style="color: #000000;">}</span></p>
<p><span style="color: #000000;">else</span></p>
<p><span style="color: #000000;">{</span></p>
<p><span style="color: #000000;">Statement //code to be execute if neither condition 1 nor condition 2 is true</span></p>
<p><span style="color: #000000;">}</span></p>
<p><span style="color: #ff0000;"><strong>Example-1</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var n=parseInt(prompt(&#8220;enter any number&#8230;&#8221;))</span><br />
<span style="color: #000000;">if (n&gt;20)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(n+ &#8221; is greater than 20&#8243;)</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">else if(n&lt;20)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(n+ &#8221; is less than 20&#8243;)</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">else if(n==20)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(n+ &#8221; is equal to 20&#8243;)</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">else</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">document.write(&#8220;Invalid Input&#8221;)</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p><span style="color: #0000ff;"><strong>First Run-</strong></span></p>
<p>Enter any number</p>
<p>14</p>
<p>14 is less than 20</p>
<p><span style="color: #0000ff;"><strong>Second Run</strong></span></p>
<p>Enter any number</p>
<p>20</p>
<p>20 is equal to 20</p>
<p><span style="color: #000000;"><strong>For Live Class on youtube click on the below link</strong></span></p>
<p><a href="https://youtu.be/yufa6arAJvU">https://youtu.be/yufa6arAJvU</a></p>
<p><span style="color: #ff0000;"><strong>Example-2</strong></span></p>
<p>&lt;html&gt;<br />
&lt;script&gt;<br />
var a=parseInt(prompt(&#8220;enter first number&#8230;&#8221;))<br />
var b=parseInt(prompt(&#8220;enter second number&#8230;&#8221;))<br />
var c=parseInt(prompt(&#8220;enter third number&#8230;&#8221;))<br />
if (a&gt;b &amp;&amp; a&gt;c)<br />
{<br />
document.write(a+ &#8221; is greater than &#8220;+b+&#8221; and &#8220;+c)<br />
}<br />
else if(b&gt;a &amp;&amp; b&gt;c)<br />
{<br />
document.write(b+ &#8221; is greater than &#8220;+a+&#8221; and &#8221; +c)<br />
}</p>
<p>else<br />
{<br />
document.write(c+&#8221; greater than &#8220;+b+&#8221; and &#8220;+a)<br />
}<br />
&lt;/script&gt;<br />
&lt;/html&gt;</p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p>enter first number&#8230; 50</p>
<p>enter second number&#8230;80</p>
<p>enter third number&#8230;10</p>
<p>80 is greater than 50 and 10</p>
<p><span style="color: #ff0000;"><strong>For Full JavaScript Classes Subscribe Our YouTube Channel link is given below </strong></span></p>
<p><a href="https://www.youtube.com/@olevelguruji">https://www.youtube.com/@olevelguruji</a></p>
<p><strong><span style="color: #000000;">4) switch Statement</span></strong></p>
<p><span style="color: #000000;"> The <strong>switch</strong> statement provides an alternative way to handle multiple conditions more efficiently than chaining <strong>if&#8230;else if</strong> statements.</span></p>
<p><span style="color: #000000;">switch(n)</span></p>
<p><span style="color: #000000;">{</span></p>
<p><span style="color: #000000;">case 1:</span></p>
<p><span style="color: #000000;">execute code block 1</span></p>
<p><span style="color: #000000;">break;</span></p>
<p><span style="color: #000000;">case 2:</span></p>
<p><span style="color: #000000;">execute code block 2</span></p>
<p><span style="color: #000000;">break;</span></p>
<p><span style="color: #000000;">&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</span></p>
<p><span style="color: #000000;">&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..</span></p>
<p><span style="color: #000000;">default:</span></p>
<p><span style="color: #000000;">code to be executes if it is different from case 1 and case 2</span></p>
<p><span style="color: #000000;">}</span></p>
<p><span style="color: #ff0000;"><strong>Example-1</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var ch=parseInt(prompt(&#8220;enter your choice&#8230;&#8221;))</span><br />
<span style="color: #000000;">switch(ch)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">case 1:</span><br />
<span style="color: #000000;">document.write(&#8220;Monday&#8221;);</span><br />
<span style="color: #000000;">break;</span><br />
<span style="color: #000000;">case 2:</span><br />
<span style="color: #000000;">document.write(&#8220;Tuesday&#8221;);</span><br />
<span style="color: #000000;">break;</span><br />
<span style="color: #000000;">case 3:</span><br />
<span style="color: #000000;">document.write(&#8220;Wednesday&#8221;);</span><br />
<span style="color: #000000;">break;</span><br />
<span style="color: #000000;">case 4:</span><br />
<span style="color: #000000;">document.write(&#8220;Thursday&#8221;);</span><br />
<span style="color: #000000;">break;</span><br />
<span style="color: #000000;">case 5:</span><br />
<span style="color: #000000;">document.write(&#8220;Friday&#8221;);</span><br />
<span style="color: #000000;">break;</span><br />
<span style="color: #000000;">case 6:</span><br />
<span style="color: #000000;">document.write(&#8220;Saturday&#8221;);</span><br />
<span style="color: #000000;">break;</span><br />
<span style="color: #000000;">case 7:</span><br />
<span style="color: #000000;">document.write(&#8220;Sunday&#8221;);</span><br />
<span style="color: #000000;">break;</span><br />
<span style="color: #000000;">default:</span><br />
<span style="color: #000000;">document.write(&#8220;invalid Choice&#8230;.&#8221;)</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;">Enter your choice 3</span></p>
<p><span style="color: #000000;">Wednesday</span></p>
<p><span style="color: #000000;">Enter Your choice 9</span></p>
<p><span style="color: #000000;">Invalid Choice</span></p>
<p><strong style="color: #000000;">5) Ternary Operator (Conditional Operator):</strong></p>
<p><span style="color: #000000;"> The ternary operator (<strong>condition ? expression1 : expression2</strong>) is a concise way to write conditional statements. It evaluates a condition and returns one of two expressions based on whether the condition is true or false.</span></p>
<p><span style="color: #ff0000;"><strong>Example</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var marks = prompt(&#8216;Enter your marks :&#8217;);</span><br />
<span style="color: #000000;">// check the condition</span><br />
<span style="color: #000000;">var result = (marks &gt;= 40) ? &#8216;pass&#8217; : &#8216;fail&#8217;;</span><br />
<span style="color: #000000;">alert(result);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;">Conclusion: Conditional statements are indispensable tools in JavaScript programming for implementing logic and making decisions based on different conditions. Understanding how to use <strong>if</strong>, <strong>if&#8230;else</strong>, <strong>if&#8230;else if&#8230;else</strong>, <strong>switch</strong>, and the ternary operator enables you to write more efficient and expressive code. By mastering these conditional statements, you&#8217;ll have greater control over the flow of your JavaScript programs, paving the way for building dynamic and interactive web applications.</span></p>
<p><span style="color: #ff0000;"><strong>Also Check Our Latest Upload</strong></span></p>
<p><a href="https://careersknowledge.in/javascript-operators-with-example/">JavaScript operators with example</a></p>
<p><a href="https://careersknowledge.in/javascript-programs-examples-with-output/">JavaScript programs examples with output</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://careersknowledge.in/types-of-conditional-statements-in-javascript/">types of conditional statements in javascript</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/types-of-conditional-statements-in-javascript/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>JavaScript operators with example</title>
		<link>https://careersknowledge.in/javascript-operators-with-example/</link>
					<comments>https://careersknowledge.in/javascript-operators-with-example/#comments</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Thu, 04 Apr 2024 06:22:25 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[assignment operators in javascript]]></category>
		<category><![CDATA[conditional operator in javascript]]></category>
		<category><![CDATA[javascript logical operators]]></category>
		<category><![CDATA[Javascript operators]]></category>
		<category><![CDATA[Javascript operators examples]]></category>
		<category><![CDATA[Javascript operators list]]></category>
		<category><![CDATA[JavaScript operators with example]]></category>
		<category><![CDATA[types of operators in javascript]]></category>
		<category><![CDATA[types of operators in javascript with example]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1512</guid>

					<description><![CDATA[<p>JavaScript operators with example JavaScript, as a versatile and dynamic programming language, offers a plethora of operators that empower developers to manipulate data, perform calculations, and control program flow with precision and efficiency. In this article, we embark on a journey to unravel the intricacies of JavaScript operators, exploring their types, functionalities, and practical applications ... <a title="JavaScript operators with example" class="read-more" href="https://careersknowledge.in/javascript-operators-with-example/" aria-label="Read more about JavaScript operators with example">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/javascript-operators-with-example/">JavaScript operators with example</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1 style="text-align: center;"><span style="color: #000000;"><strong>JavaScript operators with example</strong></span></h1>
<p><span style="color: #000000;">JavaScript, as a versatile and dynamic programming language, offers a plethora of operators that empower developers to manipulate data, perform calculations, and control program flow with precision and efficiency. In this article, we embark on a journey to unravel the intricacies of JavaScript operators, exploring their types, functionalities, and practical applications in web development. In this article we will learn JavaScript operators with example. So must read the full article.</span></p>
<p><span style="color: #000000;"><strong>Understanding JavaScript Operators:</strong></span></p>
<p><span style="color: #000000;">Operators in JavaScript are symbols or keywords used to perform operations on operands. They can be classified into several categories based on their functionality:</span></p>
<ol>
<li><span style="color: #000000;"><strong>Arithmetic Operators:</strong> Arithmetic operators are used to perform mathematical calculations such as addition, subtraction, multiplication, division, and modulus. For example, <code>+</code> for addition, <code>-</code> for subtraction, <code>*</code> for multiplication, <code>/</code> for division, and <code>%</code> for modulus.</span></li>
<li><span style="color: #000000;"><strong>Assignment Operators:</strong> Assignment operators are used to assign values to variables. The most common assignment operator is <code>=</code> which assigns the value on the right-hand side to the variable on the left-hand side.</span></li>
<li><span style="color: #000000;"><strong>Comparison Operators:</strong> Comparison operators are used to compare two values and return a boolean result indicating whether the comparison is true or false. Examples include <code>==</code> for equality, <code>!=</code> for inequality, <code>&gt;</code> for greater than, <code>&lt;</code> for less than, <code>&gt;=</code> for greater than or equal to, and <code>&lt;=</code> for less than or equal to.</span></li>
<li><span style="color: #000000;"><strong>Logical Operators:</strong> Logical operators are used to combine or modify boolean values. The logical AND (<code>&amp;&amp;</code>), logical OR (<code>||</code>), and logical NOT (<code>!</code>) operators are commonly used for logical operations.</span></li>
<li><span style="color: #000000;"><strong>Unary Operators:</strong> Unary operators operate on a single operand. Examples include the unary plus (<code>+</code>) and unary minus (<code>-</code>) operators, which respectively convert the operand to a number and negate its value.</span></li>
<li><span style="color: #000000;"><strong>Ternary Operator (Conditional Operator):</strong> The ternary operator (<code>? :</code>) is a conditional operator that evaluates a condition and returns one of two expressions based on whether the condition is true or false.</span></li>
</ol>
<p><span style="color: #000000;"><strong>Practical Applications of JavaScript Operators:</strong></span></p>
<p><span style="color: #000000;">JavaScript operators find wide-ranging applications in web development:</span></p>
<ol>
<li><span style="color: #000000;"><strong>Data Manipulation:</strong> Arithmetic operators are used to perform mathematical calculations and manipulate numeric data, while string concatenation operators (<code>+</code>) are used to combine strings.</span></li>
<li><span style="color: #000000;"><strong>Control Flow:</strong> Comparison and logical operators are essential for controlling the flow of execution in JavaScript programs, enabling developers to create conditional statements and loops.</span></li>
<li><span style="color: #000000;"><strong>Form Validation:</strong> Comparison operators are commonly used in form validation scripts to compare user input against specified criteria and determine whether it meets the required conditions.</span></li>
<li><span style="color: #000000;"><strong>DOM Manipulation:</strong> Assignment operators are frequently used to assign values to properties of HTML elements, allowing developers to dynamically modify the content and behavior of web pages.</span></li>
</ol>
<p><span style="color: #ff0000;"><strong>For More JavaScript Classes Subscribe Our YouTube Channel</strong></span></p>
<p><a href="https://www.youtube.com/@olevelguruji">https://www.youtube.com/@olevelguruji</a></p>
<p><span style="color: #000000;"><strong>Best Practices for Using JavaScript Operators:</strong></span></p>
<p><span style="color: #000000;">While JavaScript operators are powerful tools, it&#8217;s essential to use them judiciously and adhere to best practices:</span></p>
<ol>
<li><span style="color: #000000;"><strong>Understand Operator Precedence:</strong> Familiarize yourself with the precedence rules governing the order of operations in JavaScript to ensure the correct evaluation of expressions.</span></li>
<li><span style="color: #000000;"><strong>Use Parentheses for Clarity:</strong> When writing complex expressions involving multiple operators, use parentheses to clarify the order of operations and improve readability.</span></li>
<li><span style="color: #000000;"><strong>Avoid Implicit Type Conversion:</strong> Be cautious when using operators that perform implicit type conversion, such as the equality (<code>==</code>) operator, to prevent unexpected behavior and potential bugs.</span></li>
<li><span style="color: #000000;"><strong>Follow Naming Conventions:</strong> Choose meaningful variable and function names that accurately convey their purpose, especially when using assignment operators to assign values.</span></li>
</ol>
<p><span style="color: #000000;"><strong>Conclusion:</strong></span></p>
<p><span style="color: #000000;">JavaScript operators are indispensable tools for web developers, empowering them to perform a wide range of operations and control program behavior with precision and efficiency. By understanding the different types of operators, their functionalities, and best practices for their usage, developers can leverage the full potential of JavaScript to create dynamic, interactive, and robust web applications. As you continue your journey in web development, mastering JavaScript operators will undoubtedly enhance your coding skills and enable you to build more sophisticated and engaging web experiences.</span></p>
<p><span style="color: #000000;">Thanks for reading the article JavaScript operators with example. I hope you will understand the topic well also share our article with your friends.</span></p>
<p><span style="color: #ff0000;"><strong>Also Check Our Latest Uploads</strong></span></p>
<p><a href="https://careersknowledge.in/javascript-programs-examples-with-output/">JavaScript programs examples with output</a></p>
<p><a href="https://careersknowledge.in/popup-boxes-in-javascript/">Popup boxes in JavaScript</a></p>
<p>The post <a href="https://careersknowledge.in/javascript-operators-with-example/">JavaScript operators with example</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/javascript-operators-with-example/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>JavaScript programs examples with output</title>
		<link>https://careersknowledge.in/javascript-programs-examples-with-output/</link>
					<comments>https://careersknowledge.in/javascript-programs-examples-with-output/#comments</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Wed, 03 Apr 2024 14:36:21 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[examples on outputting javascript on website]]></category>
		<category><![CDATA[how to output javascript on website]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript (programming language)]]></category>
		<category><![CDATA[javascript course]]></category>
		<category><![CDATA[javascript crash course]]></category>
		<category><![CDATA[javascript for beginners]]></category>
		<category><![CDATA[javascript full course]]></category>
		<category><![CDATA[javascript how to output]]></category>
		<category><![CDATA[javascript output]]></category>
		<category><![CDATA[javascript output methods]]></category>
		<category><![CDATA[javascript programming]]></category>
		<category><![CDATA[javascript programs examples with output]]></category>
		<category><![CDATA[javascript programs for practice]]></category>
		<category><![CDATA[javascript tutorial]]></category>
		<category><![CDATA[javascript tutorial for beginners]]></category>
		<category><![CDATA[learn javascript]]></category>
		<category><![CDATA[output javascript in the browser]]></category>
		<category><![CDATA[output javascript on website]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1492</guid>

					<description><![CDATA[<p>JavaScript programs examples with output Hello Guys, Welcome to our new article in the article you will get JavaScript programs examples with output. Program-1 Write a program to find addition of two number &#60;html&#62; &#60;body&#62; &#60;h1&#62;Program 1&#60;/h1&#62; &#60;script&#62; var a=50; var b=10; document.write(&#8220;Value of a=&#8221;+a); document.write(&#8220;&#60;br&#62;Value of b=&#8221;+b); document.write(&#8220;&#60;br&#62;Addition of a and b=&#8221;+c); &#60;/script&#62; &#60;/body&#62; ... <a title="JavaScript programs examples with output" class="read-more" href="https://careersknowledge.in/javascript-programs-examples-with-output/" aria-label="Read more about JavaScript programs examples with output">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/javascript-programs-examples-with-output/">JavaScript programs examples with output</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1 style="text-align: center;"><strong><span style="color: #000000;">JavaScript programs examples with output</span></strong></h1>
<p>Hello Guys, Welcome to our new article in the article you will get JavaScript programs examples with output.</p>
<p><span style="color: #ff0000;"><strong>Program-1 Write a program to find addition of two number</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;Program 1&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var a=50;</span><br />
<span style="color: #000000;">var b=10;</span><br />
<span style="color: #000000;">document.write(&#8220;Value of a=&#8221;+a);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Value of b=&#8221;+b);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Addition of a and b=&#8221;+c);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #ff0000;"><strong>Program-1 Write a program to find addition,Subtraction,Multiplication and  Divison of two number.</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;Program 1&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var a=50;</span><br />
<span style="color: #000000;">var b=10;</span><br />
<span style="color: #000000;">var c=a+b;</span><br />
<span style="color: #000000;">var d=a-b;</span><br />
<span style="color: #000000;">var e=a*b;</span><br />
<span style="color: #000000;">var f=a/b;</span><br />
<span style="color: #000000;">document.write(&#8220;Value of a=&#8221;+a);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Value of b=&#8221;+b);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Addition of a and b=&#8221;+c);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Subtraction of a and b=&#8221;+d);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Multiplication of a and b=&#8221;+e);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Division of a and b=&#8221;+f);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1493 size-full" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptprogram.png" alt="JavaScript programs examples with output" width="434" height="380" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprogram.png 434w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprogram-324x284.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprogram-300x263.png 300w" sizes="auto, (max-width: 434px) 100vw, 434px" /></span></p>
<p><span style="color: #ff0000;"><strong>Program-2 Write a program to print simple interest</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;Program 2&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;p&gt;My first paragraph.&lt;/p&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var p=5000;</span><br />
<span style="color: #000000;">var r=3;</span><br />
<span style="color: #000000;">var t=2;</span><br />
<span style="color: #000000;">var si=p*r*t/100;</span><br />
<span style="color: #000000;">document.write(&#8220;Principle Amount=&#8221;+p);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Rate of interest=&#8221;+r);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Time=&#8221;+t);</span><br />
<span style="color: #000000;">window.alert(&#8220;Simple Interest=&#8221;+si);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1494" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptsimpleinterestprogram.png" alt="" width="499" height="401" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptsimpleinterestprogram.png 499w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptsimpleinterestprogram-324x260.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptsimpleinterestprogram-300x241.png 300w" sizes="auto, (max-width: 499px) 100vw, 499px" /></span></p>
<p><span style="color: #ff0000;"><strong>Program-3 Write a program to find area of circle.</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;Program 3&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var r=3.5</span><br />
<span style="color: #000000;">var area=3.14*r*r</span><br />
<span style="color: #000000;">document.write(&#8220;Area of circle=&#8221;+area);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1495" src="http://careersknowledge.in/wp-content/uploads/2024/04/areaofcicleprogram.png" alt="" width="398" height="227" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/areaofcicleprogram.png 398w, https://careersknowledge.in/wp-content/uploads/2024/04/areaofcicleprogram-324x185.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/areaofcicleprogram-300x171.png 300w" sizes="auto, (max-width: 398px) 100vw, 398px" /></span></p>
<p><strong>For Live Class on YouTube click on the below link </strong></p>
<p><a href="https://youtu.be/1S_iRvy4HMU">https://youtu.be/1S_iRvy4HMU</a></p>
<p><span style="color: #ff0000;"><strong>Program-4 Write a program to find the volume of cylinder and volume of cone</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;Program 4&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var r1=3.5</span><br />
<span style="color: #000000;">var r2=5.2</span><br />
<span style="color: #000000;">var h1=7</span><br />
<span style="color: #000000;">var h2=9</span><br />
<span style="color: #000000;">var vol1=3.14*r1*r1*h1</span><br />
<span style="color: #000000;">var vol2=3.14*r2*r2*h2/3</span><br />
<span style="color: #000000;">document.write(&#8220;volumn of Cylinder=&#8221;+vol1);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;volumn of Cone=&#8221;+vol2);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1496 size-full" src="http://careersknowledge.in/wp-content/uploads/2024/04/volumeofcylinderandconeprogram.png" alt="JavaScript programs examples with output" width="837" height="364" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/volumeofcylinderandconeprogram.png 837w, https://careersknowledge.in/wp-content/uploads/2024/04/volumeofcylinderandconeprogram-324x141.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/volumeofcylinderandconeprogram-300x130.png 300w, https://careersknowledge.in/wp-content/uploads/2024/04/volumeofcylinderandconeprogram-768x334.png 768w" sizes="auto, (max-width: 837px) 100vw, 837px" /></span></p>
<p><span style="color: #ff0000;"><strong>Program 5- Write a program to enter unit price and quantity and print gross bill amount,net bill amount and discount. (Discount=5%)</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;Program 5&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var p=10 ;</span><br />
<span style="color: #000000;">var q=100;</span><br />
<span style="color: #000000;">var gba=q*p;</span><br />
<span style="color: #000000;">var dis=gba*5/100;</span><br />
<span style="color: #000000;">var nba=gba-dis</span><br />
<span style="color: #000000;">document.write(&#8220;Gross Bill Amount=&#8221;+gba);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Discount=&#8221;+dis);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Net Bill Amount=&#8221;+nba);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1497" src="http://careersknowledge.in/wp-content/uploads/2024/04/netbillamountprogram.png" alt="" width="455" height="278" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/netbillamountprogram.png 455w, https://careersknowledge.in/wp-content/uploads/2024/04/netbillamountprogram-324x198.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/netbillamountprogram-300x183.png 300w" sizes="auto, (max-width: 455px) 100vw, 455px" /></span></p>
<p><span style="color: #000000;">Now, here we completed the program where we provide the values in a program. In the next we will see Values enter at run time.</span></p>
<p><strong><span style="color: #ff0000;">Program-6</span></strong></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var a1=parseInt(prompt(&#8220;Enter the value of a1 for addition&#8221;));</span><br />
<span style="color: #000000;">var b1=parseInt(prompt(&#8220;Enter the value of b1 for addition&#8221;));</span><br />
<span style="color: #000000;">var a2=parseInt(prompt(&#8220;Enter the value of a2 for subtraction&#8221;));</span><br />
<span style="color: #000000;">var b2=parseInt(prompt(&#8220;Enter the value of b2 for subtraction&#8221;));</span><br />
<span style="color: #000000;">var a3=parseInt(prompt(&#8220;Enter the value of a3 for multiplication&#8221;));</span><br />
<span style="color: #000000;">var b3=parseInt(prompt(&#8220;Enter the value of b3 for multiplication&#8221;));</span><br />
<span style="color: #000000;">var a4=parseInt(prompt(&#8220;Enter the value of a4 for multiplication&#8221;));</span><br />
<span style="color: #000000;">var b4=parseInt(prompt(&#8220;Enter the value of b4 for multiplication&#8221;));</span><br />
<span style="color: #000000;">c=a1+b1;</span><br />
<span style="color: #000000;">d=a2-b2;</span><br />
<span style="color: #000000;">e=a3*b3;</span><br />
<span style="color: #000000;">f=a4/b4;</span><br />
<span style="color: #000000;">document.write(&#8220;Addition=&#8221;+c);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Subtraction=&#8221;+d);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Multiplication=&#8221;+e);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Division=&#8221;+f);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1499 size-full" src="http://careersknowledge.in/wp-content/uploads/2024/04/runtimejavascriptprogram.png" alt="JavaScript programs examples with output" width="766" height="255" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/runtimejavascriptprogram.png 766w, https://careersknowledge.in/wp-content/uploads/2024/04/runtimejavascriptprogram-324x108.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/runtimejavascriptprogram-300x100.png 300w" sizes="auto, (max-width: 766px) 100vw, 766px" /></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1500" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptprograms.png" alt="" width="690" height="259" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprograms.png 690w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprograms-324x122.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprograms-300x113.png 300w" sizes="auto, (max-width: 690px) 100vw, 690px" /></span></p>
<p><span style="color: #000000;">Similarly you can provide the other variable values finally here you will see the output after entering all the values.</span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1501" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptexample.png" alt="" width="590" height="385" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptexample.png 590w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptexample-324x211.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptexample-300x196.png 300w" sizes="auto, (max-width: 590px) 100vw, 590px" /></span></p>
<p><span style="color: #000000;"><strong>For Live Class Watch our video on YouTube by click on the below link</strong></span></p>
<p><a href="https://youtu.be/MEVKaDPIrUE">https://youtu.be/MEVKaDPIrUE</a></p>
<p><span style="color: #ff0000;"><strong>Program-7</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var p=parseInt(prompt(&#8220;enter principle amt&#8221;))</span><br />
<span style="color: #000000;">var r=parseInt(prompt(&#8220;enter rate of interest&#8221;))</span><br />
<span style="color: #000000;">var t=parseInt(prompt(&#8220;enter time period&#8221;))</span><br />
<span style="color: #000000;">si=p*r*t/100</span><br />
<span style="color: #000000;">document.write(&#8220;Simple Interest=&#8221;+si);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1502 size-full" src="http://careersknowledge.in/wp-content/uploads/2024/04/simpleinterestprogram.png" alt="JavaScript programs examples with output" width="618" height="208" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/simpleinterestprogram.png 618w, https://careersknowledge.in/wp-content/uploads/2024/04/simpleinterestprogram-324x109.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/simpleinterestprogram-300x101.png 300w" sizes="auto, (max-width: 618px) 100vw, 618px" /></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1503" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptprogramruntime.png" alt="" width="500" height="188" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprogramruntime.png 500w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprogramruntime-324x122.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprogramruntime-300x113.png 300w" sizes="auto, (max-width: 500px) 100vw, 500px" /></span></p>
<p>&nbsp;</p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1505" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptexamples.png" alt="" width="483" height="188" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptexamples.png 483w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptexamples-324x126.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptexamples-300x117.png 300w" sizes="auto, (max-width: 483px) 100vw, 483px" /></span></p>
<p><span style="color: #000000;">Finally after providing the values you will get the below output</span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1506" src="http://careersknowledge.in/wp-content/uploads/2024/04/simpleinterestprogram-1.png" alt="" width="507" height="116" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/simpleinterestprogram-1.png 507w, https://careersknowledge.in/wp-content/uploads/2024/04/simpleinterestprogram-1-324x74.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/simpleinterestprogram-1-300x69.png 300w" sizes="auto, (max-width: 507px) 100vw, 507px" /></span></p>
<p><span style="color: #ff0000;"><strong>Program-8 </strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var r=parseInt(prompt(&#8220;Enter radius for circle..&#8221;))</span><br />
<span style="color: #000000;">var r1=parseInt(prompt(&#8220;Enter radius for cylinder..&#8221;))</span><br />
<span style="color: #000000;">var h1=parseInt(prompt(&#8220;Enter height for cylinder..&#8221;))</span><br />
<span style="color: #000000;">var r2=parseInt(prompt(&#8220;Enter radius for cone..&#8221;))</span><br />
<span style="color: #000000;">var h2=parseInt(prompt(&#8220;Enter height for cone..&#8221;))</span><br />
<span style="color: #000000;">area=3.14*r*r;</span><br />
<span style="color: #000000;">vol1=3.14*r1*r1*h1;</span><br />
<span style="color: #000000;">vol2=3.14*r2*r2*h2/3;</span><br />
<span style="color: #000000;">document.write(&#8220;Area of circle=&#8221;+area);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Volumn of cylinder=&#8221;+vol1);</span><br />
<span style="color: #000000;">document.write(&#8220;&lt;br&gt;Volumn of cone=&#8221;+vol2);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;">Output-</span></p>
<p><span style="color: #000000;">Here we provide the r=5,r1=7,h1=11,r2=8,h2=13, then you will get the following output</span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1507" src="http://careersknowledge.in/wp-content/uploads/2024/04/areaofcirclevolumeofcylinder.png" alt="" width="615" height="179" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/areaofcirclevolumeofcylinder.png 615w, https://careersknowledge.in/wp-content/uploads/2024/04/areaofcirclevolumeofcylinder-324x94.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/areaofcirclevolumeofcylinder-300x87.png 300w" sizes="auto, (max-width: 615px) 100vw, 615px" /></span></p>
<p>&nbsp;</p>
<p><span style="color: #000000;">Thanks For Reading our Article JavaScript programs examples with output. Also share this article.</span></p>
<p><span style="color: #ff0000;"><strong>Also Check Our Latest Uploads</strong></span></p>
<p><a href="https://careersknowledge.in/popup-boxes-in-javascript/">Popup boxes in JavaScript</a></p>
<p><a href="https://careersknowledge.in/inbound-and-outbound-digital-marketing/">Inbound and Outbound Digital Marketing</a></p>
<p><a href="https://careersknowledge.in/what-are-the-javascript-data-types/">What are the JavaScript data types</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://careersknowledge.in/javascript-programs-examples-with-output/">JavaScript programs examples with output</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/javascript-programs-examples-with-output/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Popup boxes in JavaScript</title>
		<link>https://careersknowledge.in/popup-boxes-in-javascript/</link>
					<comments>https://careersknowledge.in/popup-boxes-in-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Tue, 02 Apr 2024 17:05:40 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[confirm box in javascript]]></category>
		<category><![CDATA[How to use popup boxes in javascript]]></category>
		<category><![CDATA[javascript popup window onclick]]></category>
		<category><![CDATA[popup box in javascript example]]></category>
		<category><![CDATA[Popup boxes in javascript]]></category>
		<category><![CDATA[prompt box in javascript]]></category>
		<category><![CDATA[Types of popup boxes in javascript]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1477</guid>

					<description><![CDATA[<p>Popup boxes in JavaScript In the realm of web development, interactivity and user engagement are paramount. JavaScript, as a powerful scripting language, offers a multitude of tools to enhance user experience, one of which is the JavaScript Popup Box. In this article, we delve into the world of JavaScript Popup Boxes, exploring their functionality, usage, ... <a title="Popup boxes in JavaScript" class="read-more" href="https://careersknowledge.in/popup-boxes-in-javascript/" aria-label="Read more about Popup boxes in JavaScript">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/popup-boxes-in-javascript/">Popup boxes in JavaScript</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1 style="text-align: center;"><span style="color: #000000;"><strong>Popup boxes in JavaScript</strong></span></h1>
<p><span style="color: #000000;">In the realm of web development, interactivity and user engagement are paramount. JavaScript, as a powerful scripting language, offers a multitude of tools to enhance user experience, one of which is the JavaScript Popup Box. In this article, we delve into the world of JavaScript Popup Boxes, exploring their functionality, usage, and the myriad ways they can elevate web applications.</span></p>
<h3 style="text-align: left;"><span style="color: #000000;"><strong>Understanding JavaScript Popup Boxes:</strong></span></h3>
<p><span style="color: #000000;">JavaScript Popup Boxes, also known as JavaScript Dialog Boxes, are interactive elements that appear on a web page to communicate messages, gather user input, or prompt for confirmation. They provide a simple yet effective means of interacting with users, enhancing the usability and functionality of web applications.</span></p>
<p><span style="color: #000000;"><strong>Types of JavaScript Popup Boxes:</strong></span></p>
<p><span style="color: #000000;">There are several types of JavaScript Popup Boxes, each serving a specific purpose:</span></p>
<p><span style="color: #000000;"><strong>1) Alert Box (warning)</strong></span></p>
<p><span style="color: #000000;">An alert box is often used if you want to make sure information comes through the user. When an alert box pop up,the user will have to click ok to proceed.</span></p>
<p><span style="color: #000000;">syntax-</span></p>
<p><span style="color: #000000;">alert(&#8220;message&#8221;);</span></p>
<p><span style="color: #ff0000;"><strong>Example-1</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">window.alert(&#8220;Welcome in javascript&#8230;.&#8221;);</span><br />
<span style="color: #000000;">window.alert(&#8220;Thank U&#8230;.&#8221;);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1479 size-large" src="http://careersknowledge.in/wp-content/uploads/2024/04/alertbox-1-1024x199.png" alt="Popup boxes in JavaScript" width="1024" height="199" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/alertbox-1-1024x199.png 1024w, https://careersknowledge.in/wp-content/uploads/2024/04/alertbox-1-324x63.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/alertbox-1-300x58.png 300w, https://careersknowledge.in/wp-content/uploads/2024/04/alertbox-1-768x149.png 768w, https://careersknowledge.in/wp-content/uploads/2024/04/alertbox-1.png 1226w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></span></p>
<p><span style="color: #ff0000;"><strong>Example-2</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;head&gt;</span><br />
<span style="color: #000000;">&lt;script&gt; </span><br />
<span style="color: #000000;">function myAlert()</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">window.alert(&#8220;Welcome in my Alert function&#8230;.&#8221;);</span><br />
<span style="color: #000000;">window.alert(&#8220;Thank u for visit&#8230;&#8221;);</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/head&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;Click on the button to display the alert message&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;input type=&#8221;button&#8221; value=&#8221;Click Me&#8221; onclick=&#8221;myAlert()&#8221;&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1480 size-large" src="http://careersknowledge.in/wp-content/uploads/2024/04/alertboxwithbutton-1024x223.png" alt="Popup boxes in JavaScript" width="1024" height="223" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/alertboxwithbutton-1024x223.png 1024w, https://careersknowledge.in/wp-content/uploads/2024/04/alertboxwithbutton-324x71.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/alertboxwithbutton-300x65.png 300w, https://careersknowledge.in/wp-content/uploads/2024/04/alertboxwithbutton-768x167.png 768w, https://careersknowledge.in/wp-content/uploads/2024/04/alertboxwithbutton.png 1280w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></span></p>
<p><span style="color: #000000;">When You click on the Click me button than you will get the below output</span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1481" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptalert-1024x151.png" alt="" width="1024" height="151" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptalert-1024x151.png 1024w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptalert-324x48.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptalert-300x44.png 300w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptalert-768x113.png 768w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptalert.png 1236w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></span></p>
<p><span style="color: #000000;">When you click on the ok button than you will get the next alert box message.</span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1482 size-large" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptpop-1024x196.png" alt="Popup boxes in JavaScript" width="1024" height="196" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptpop-1024x196.png 1024w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptpop-324x62.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptpop-300x57.png 300w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptpop-768x147.png 768w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptpop.png 1233w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></span></p>
<p><strong><span style="color: #000000;">2) Confirm Box(Yes/No)</span></strong></p>
<p><span style="color: #000000;">It is often used if you want the user to verify or accept something. When a comfirm box pop up, the user will have to click either &#8220;OK&#8221; or &#8220;Cancel&#8221; to proceed.</span><br />
<span style="color: #000000;">Syntax-</span><br />
<span style="color: #000000;">confirm(&#8220;message&#8221;);</span></p>
<p><span style="color: #ff0000;"><strong>Example-1</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;head&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var c=confirm(&#8220;Click OK or Cancel&#8221;)</span><br />
<span style="color: #000000;">alert(&#8220;User Clicked on &#8221; +c)</span></p>
<p><span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/head&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;">Output</span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1483" src="http://careersknowledge.in/wp-content/uploads/2024/04/confirmbox.png" alt="" width="747" height="252" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/confirmbox.png 747w, https://careersknowledge.in/wp-content/uploads/2024/04/confirmbox-324x109.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/confirmbox-300x101.png 300w" sizes="auto, (max-width: 747px) 100vw, 747px" /></span></p>
<p><strong><span style="color: #000000;">When you click on ok button then you will get the below output</span></strong></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1484 size-full" src="http://careersknowledge.in/wp-content/uploads/2024/04/javacsriptconfirm.png" alt="Popup boxes in JavaScript" width="642" height="265" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javacsriptconfirm.png 642w, https://careersknowledge.in/wp-content/uploads/2024/04/javacsriptconfirm-324x134.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javacsriptconfirm-300x124.png 300w" sizes="auto, (max-width: 642px) 100vw, 642px" /></span></p>
<p><span style="color: #ff0000;"><strong>Example-2</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;head&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var c=confirm(&#8220;click on ok or cancel button&#8221;)</span><br />
<span style="color: #000000;">if(c==true)</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">alert(&#8220;User click on OK Button&#8221;);</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">else</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;">alert(&#8220;User click on Cancel Button&#8221;);</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/head&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1485" src="http://careersknowledge.in/wp-content/uploads/2024/04/confirmboxexample.png" alt="" width="659" height="209" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/confirmboxexample.png 659w, https://careersknowledge.in/wp-content/uploads/2024/04/confirmboxexample-324x103.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/confirmboxexample-300x95.png 300w" sizes="auto, (max-width: 659px) 100vw, 659px" /></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1486" src="http://careersknowledge.in/wp-content/uploads/2024/04/javacsriptconfirm-1.png" alt="" width="642" height="265" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javacsriptconfirm-1.png 642w, https://careersknowledge.in/wp-content/uploads/2024/04/javacsriptconfirm-1-324x134.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javacsriptconfirm-1-300x124.png 300w" sizes="auto, (max-width: 642px) 100vw, 642px" /></span></p>
<p><strong><span style="color: #000000;">3) Prompt Box-</span></strong></p>
<p><span style="color: #000000;">A Prompt box often used if you want to the user to the user to input a value before entering a page. When a prompt box pop up, the user will have to click either &#8220;OK&#8221; or &#8220;Cancel&#8221; to proceed after entering an input value. If the user click on ok the box return the input value. if the user click &#8220;cancel&#8221; the box return &#8220;null&#8221;</span><br />
<span style="color: #000000;">syntax-</span></p>
<p><span style="color: #000000;">prompt(&#8220;Some text..&#8221;,&#8221;default value&#8221;)</span></p>
<p><span style="color: #ff0000;"><strong>Example</strong></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;head&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">var myval=prompt(&#8220;enter any valid number&#8230;&#8221;,1000);</span><br />
<span style="color: #000000;">alert(&#8220;Enter value is &#8220;+myval);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/head&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1487" src="http://careersknowledge.in/wp-content/uploads/2024/04/promptbox.png" alt="" width="908" height="304" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/promptbox.png 908w, https://careersknowledge.in/wp-content/uploads/2024/04/promptbox-324x108.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/promptbox-300x100.png 300w, https://careersknowledge.in/wp-content/uploads/2024/04/promptbox-768x257.png 768w" sizes="auto, (max-width: 908px) 100vw, 908px" /></span></p>
<p><strong><span style="color: #000000;">When you click on the ok button</span></strong></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1488" src="http://careersknowledge.in/wp-content/uploads/2024/04/javascriptprompt.png" alt="" width="795" height="280" srcset="https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprompt.png 795w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprompt-324x114.png 324w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprompt-300x106.png 300w, https://careersknowledge.in/wp-content/uploads/2024/04/javascriptprompt-768x270.png 768w" sizes="auto, (max-width: 795px) 100vw, 795px" /></span></p>
<p><span style="color: #ff0000;"><strong>For Live Class Watch our Class on YouTube by click on the below link</strong></span></p>
<p><a href="https://youtu.be/1S_iRvy4HMU">https://youtu.be/1S_iRvy4HMU</a></p>
<p><span style="color: #000000;"><strong>Usage of JavaScript Popup Boxes:</strong></span></p>
<p><span style="color: #000000;">JavaScript Popup Boxes find wide-ranging applications in web development:</span></p>
<ol>
<li><span style="color: #000000;"><strong>Validation:</strong> Alert Boxes can be used to alert users of input errors or incomplete form submissions, guiding them to correct their mistakes before proceeding.</span></li>
<li><span style="color: #000000;"><strong>Confirmation:</strong> Confirm Boxes are utilized to confirm critical actions, such as deleting a file or unsubscribing from a service, reducing the likelihood of accidental actions.</span></li>
<li><span style="color: #000000;"><strong>User Input:</strong> Prompt Boxes facilitate the collection of user input, enabling interactive features such as search functionality, user registration forms, and personalized settings.</span></li>
<li><span style="color: #000000;"><strong>Feedback and Notifications:</strong> Popup Boxes can be employed to provide feedback or notifications to users, keeping them informed about updates, new features, or system status.</span></li>
</ol>
<p><span style="color: #000000;"><strong>Best Practices for Implementing JavaScript Popup Boxes:</strong></span></p>
<p><span style="color: #000000;">While JavaScript Popup Boxes are valuable tools, their overuse or misuse can disrupt the user experience. Here are some best practices for implementing them effectively:</span></p>
<ol>
<li><span style="color: #000000;"><strong>Use Sparingly:</strong> Avoid overwhelming users with excessive Popup Boxes. Reserve them for important messages or interactions that require immediate attention.</span></li>
<li><span style="color: #000000;"><strong>Provide Clear Messaging:</strong> Ensure that the content of Popup Boxes is concise, informative, and easy to understand. Use clear language and appropriate formatting to convey messages effectively.</span></li>
<li><span style="color: #000000;"><strong>Offer Options:</strong> When using Confirm Boxes, provide clear options for users to confirm or cancel actions. Use descriptive button labels to indicate the consequences of each choice.</span></li>
<li><span style="color: #000000;"><strong>Handle User Input Safely:</strong> When using Prompt Boxes to collect user input, validate and sanitize the input data to prevent security vulnerabilities or unintended behavior.</span></li>
</ol>
<p><span style="color: #000000;"><strong>Conclusion:</strong></span></p>
<p><span style="color: #000000;">JavaScript Popup Boxes are versatile tools that play a vital role in enhancing user interaction and engagement on the web. By judiciously implementing Alert Boxes, Confirm Boxes, and Prompt Boxes, web developers can create dynamic, user-friendly applications that effectively communicate messages, gather input, and streamline user interactions. As with any interactive element, it&#8217;s essential to use JavaScript Popup Boxes thoughtfully, keeping the user experience at the forefront of design decisions. With the right approach, JavaScript Popup Boxes can significantly enhance the functionality and usability of web applications, creating a more immersive and enjoyable experience for users.</span></p>
<p><strong><span style="color: #ff0000;">Also Check Our Latest Uploads</span></strong></p>
<p><a href="https://careersknowledge.in/what-are-the-javascript-data-types/">What are the JavaScript data types</a></p>
<p><a href="https://careersknowledge.in/javascript-innerhtml-document-write-window-alert/">JavaScript innerHTML document.write() window.alert()</a></p>
<p>The post <a href="https://careersknowledge.in/popup-boxes-in-javascript/">Popup boxes in JavaScript</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/popup-boxes-in-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What are the JavaScript data types</title>
		<link>https://careersknowledge.in/what-are-the-javascript-data-types/</link>
					<comments>https://careersknowledge.in/what-are-the-javascript-data-types/#respond</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Sat, 30 Mar 2024 16:56:15 +0000</pubDate>
				<category><![CDATA[10th Career Option]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[How many JavaScript data types are there?]]></category>
		<category><![CDATA[How many types of JavaScript are there?]]></category>
		<category><![CDATA[What are the 7 data types in JavaScript?]]></category>
		<category><![CDATA[What are the JavaScript data types]]></category>
		<category><![CDATA[कितने जावास्क्रिप्ट डेटा प्रकार हैं?]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1448</guid>

					<description><![CDATA[<p>JavaScript data types JavaScript variables can hold different data types: numbers, strings, objects and more: let length = 16;                                                                           // Number let lastName = &#8220;shubh&#8221;;                                                            // ... <a title="What are the JavaScript data types" class="read-more" href="https://careersknowledge.in/what-are-the-javascript-data-types/" aria-label="Read more about What are the JavaScript data types">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/what-are-the-javascript-data-types/">What are the JavaScript data types</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1 style="text-align: center;"><strong><span style="color: #000000;">JavaScript data types</span></strong></h1>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1458" src="http://careersknowledge.in/wp-content/uploads/2024/03/1_XJk99lqJkf210rSlSJm1kQ@2x-1.jpg" alt="" width="784" height="391" srcset="https://careersknowledge.in/wp-content/uploads/2024/03/1_XJk99lqJkf210rSlSJm1kQ@2x-1.jpg 784w, https://careersknowledge.in/wp-content/uploads/2024/03/1_XJk99lqJkf210rSlSJm1kQ@2x-1-324x162.jpg 324w, https://careersknowledge.in/wp-content/uploads/2024/03/1_XJk99lqJkf210rSlSJm1kQ@2x-1-300x150.jpg 300w, https://careersknowledge.in/wp-content/uploads/2024/03/1_XJk99lqJkf210rSlSJm1kQ@2x-1-768x383.jpg 768w" sizes="auto, (max-width: 784px) 100vw, 784px" /></p>
<p><span style="color: #000000;">JavaScript variables can hold different data types: numbers, strings, objects and more:</span><br />
<span style="color: #000000;">let length = 16;                                                                           // Number</span></p>
<p><span style="color: #000000;">let lastName = &#8220;shubh&#8221;;                                                            // String </span></p>
<p><span style="color: #000000;">let x = {firstName:&#8221;shubh, lastName:&#8221;laxakar&#8221;};                   // Object</span></p>
<h2 style="text-align: center;"><strong><span style="color: #000000;">The Concept of Data Types</span></strong></h2>
<p><span style="color: #000000;">In programming, data types is an important concept.</span><span style="color: #000000;">To be able to operate on variables, it is important to know something about the type.</span><span style="color: #000000;">Without data types, a computer cannot safely solve this:</span></p>
<p><span style="color: #000000;">let x = 16 + &#8220;xuv700&#8221;;</span></p>
<p><span style="color: #000000;">Result: 16xuv700</span><br />
<span style="color: #000000;">Does it make any sense to add &#8220;Volvo&#8221; to sixteen? Will it produce an error or will it produce a result?</span></p>
<p><span style="color: #000000;">JavaScript will treat the example above as:</span></p>
<p><span style="color: #000000;">let x = &#8220;16&#8221; + &#8220;xuv700&#8221;;</span></p>
<p><span style="color: #000000;">When adding a number and a string, JavaScript will treat the number as a string.</span><br />
<span style="color: #000000;">JavaScript evaluates expressions from left to right. Different sequences can produce different results:</span></p>
<p><span style="color: #000000;">let x = 16 + 4 + &#8220;xuv700&#8221;;</span></p>
<p><span style="color: #000000;">Result: 20xuv700</span></p>
<p><span style="color: #000000;">let x = &#8220;Volvo&#8221; + 16 + 4;</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">JavaScript Types are Dynamic</span></strong></h3>
<p><span style="color: #000000;">JavaScript has dynamic types. This means that the same variable can be used to hold different data types:</span></p>
<h5><span style="color: #000000;">#Example</span></h5>
<p><span style="color: #000000;">let x;                            // Now x is undefined</span></p>
<p><span style="color: #000000;">x = 5;                           // Now x is a Number x = &#8220;John&#8221;;     // Now x is a String</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">JavaScript Strings</span></strong></h3>
<p><span style="color: #000000;">A string (or a text string) is a series of characters like &#8220;John Doe&#8221;. Strings are written with quotes. You can use single or double quotes:</span></p>
<p><span style="color: #000000;">You can use quotes inside a string, as long as they don&#8217;t match the quotes surrounding the string:</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">let answer1 = &#8220;It&#8217;s alright&#8221;;                       // Single quote inside double quotes</span></p>
<p><span style="color: #000000;"> let answer2 = &#8220;He is called &#8216;Johnny'&#8221;; // Single quotes inside double quotes </span></p>
<p><span style="color: #000000;">let answer3 = &#8216;He is called &#8220;Johnny&#8221;&#8216;; // Double quotes inside single quotes</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">JavaScript Numbers</span></strong></h3>
<p><span style="color: #000000;">JavaScript has only one type of numbers. Numbers can be written with, or without decimals:</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">let x1 = 34.00;                   // Written with decimals let x2 = 34;       // Written without decimals</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">JavaScript Booleans</span></strong></h3>
<p><span style="color: #000000;">Booleans can only have two values: true or false.</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">let x = 5; let y = 5; let z = 6;</span></p>
<p><span style="color: #000000;">(x == y)    // Returns true</span></p>
<p><span style="color: #000000;">(x == z)    // Returns false</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">JavaScript Arrays</span></strong></h3>
<p><span style="color: #000000;">JavaScript arrays are written with square brackets. Array items are separated by commas.</span></p>
<p><span style="color: #000000;">The following code declares (creates) an array called cars, containing three items (car names):</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">const cars = [&#8220;Saab&#8221;, &#8220;Volvo&#8221;, &#8220;BMW&#8221;];</span></p>
<p><span style="color: #000000;">Array indexes are zero-based, which means the first item is [0], second is [1], and so on.</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">JavaScript Objects</span></strong></h3>
<p><span style="color: #000000;">JavaScript objects are written with curly braces {}.</span></p>
<p><span style="color: #000000;">Object properties are written as name:value pairs, separated by commas.</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">const person = {firstName:&#8221;John&#8221;, lastName:&#8221;Doe&#8221;, age:50, eyeColor:&#8221;blue&#8221;};</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">The typeof Operator</span></strong></h3>
<p><span style="color: #000000;">You can use the JavaScript typeof operator to find the type of a JavaScript variable. The typeof operator returns the type of a variable or an expression:</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">typeof &#8220;&#8221;                                // Returns &#8220;string&#8221;</span></p>
<p><span style="color: #000000;">typeof &#8220;John&#8221;                         // Returns &#8220;string&#8221; typeof &#8220;John Doe&#8221;                                              // Returns &#8220;string&#8221;</span></p>
<p><span style="color: #000000;">typeof 0                                 // Returns &#8220;number&#8221;</span></p>
<p><span style="color: #000000;">typeof 314                             // Returns &#8220;number&#8221;</span></p>
<p><span style="color: #000000;">typeof 3.14                            // Returns &#8220;number&#8221;</span></p>
<p><span style="color: #000000;">typeof (3)                               // Returns &#8220;number&#8221; typeof (3 + 4)                                              // Returns &#8220;number&#8221;</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">Undefined</span></strong></h3>
<p><span style="color: #000000;">In JavaScript, a variable without a value, has the value undefined. The type is also undefined.</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">let car;              // Value is undefined, type is undefined</span></p>
<p><span style="color: #000000;">car = undefined;                // Value is undefined, type is undefined</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">Empty Values</span></strong></h3>
<p><span style="color: #000000;">An empty value has nothing to do with undefined. An empty string has both a legal value and a type.</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">let car = &#8220;&#8221;;      // The value is &#8220;&#8221;, the typeof is &#8220;string</span></p>
<p>For Live Class Watch our Video on youtube link is given below\</p>
<p><a href="https://youtu.be/kw3BDN4ecrc">https://youtu.be/kw3BDN4ecrc</a></p>
<h3 style="text-align: center;"><span style="color: #000000;"><strong>Detailed Example of Datatype</strong></span></h3>
<p><span style="color: #000080;">&lt;html&gt;</span><br />
<span style="color: #000080;">&lt;body&gt;</span><br />
<span style="color: #000080;">&lt;h2&gt;JavaScript Variables&lt;/h2&gt;</span><br />
<span style="color: #000080;">&lt;p&gt;In this example, x, y, and z are variables.&lt;/p&gt;</span><br />
<span style="color: #000080;">&lt;p id=&#8221;demo&#8221;&gt;&lt;/p&gt;</span><br />
<span style="color: #000080;">&lt;script&gt;</span><br />
<span style="color: #000080;">let x = 5; </span><br />
<span style="color: #000080;">let y = &#8220;shubh&#8221;; </span><br />
<span style="color: #000080;">let z=&#8221;&#8221;;</span><br />
<span style="color: #000080;">const person = {firstName:&#8221;John&#8221;, lastName:&#8221;Doe&#8221;, age:50, eyeColor:&#8221;blue&#8221;};</span><br />
<span style="color: #000080;">const cars = [&#8220;xuv700&#8221;, &#8220;Volvo&#8221;, &#8220;BMW&#8221;];</span><br />
<span style="color: #000080;">document.write(&#8220;Car Name=&#8221; +cars[0]);</span><br />
<span style="color: #000080;">document.write(&#8220;&lt;br&gt;Car Name=&#8221; +cars[1]);</span><br />
<span style="color: #000080;">document.write(&#8220;&lt;br&gt;Car Name=&#8221; +cars[2])</span><br />
<span style="color: #000080;">document.write(&#8220;&lt;br&gt;X=&#8221;+x)</span><br />
<span style="color: #000080;">document.write(&#8220;&lt;br&gt; Type of x=&#8221;+typeof(x))</span><br />
<span style="color: #000080;">document.write(&#8220;&lt;br&gt; Type of y=&#8221;+typeof(y))</span><br />
<span style="color: #000080;">document.write(&#8220;&lt;br&gt; Type of Person=&#8221;+typeof(person))</span><br />
<span style="color: #000080;">document.write(&#8220;&lt;br&gt; Type of Cars=&#8221;+typeof(cars))</span><br />
<span style="color: #000080;">document.write(&#8220;&lt;br&gt; Type of z=&#8221;+typeof(z))</span><br />
<span style="color: #000080;">&lt;/script&gt;</span><br />
<span style="color: #000080;">&lt;/body&gt;</span><br />
<span style="color: #000080;">&lt;/html&gt;</span></p>
<p><strong>Output</strong></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1452 size-full" src="http://careersknowledge.in/wp-content/uploads/2024/03/javascript-non-primitive-data-type-example.png" alt="What are the JavaScript data types" width="714" height="591" srcset="https://careersknowledge.in/wp-content/uploads/2024/03/javascript-non-primitive-data-type-example.png 714w, https://careersknowledge.in/wp-content/uploads/2024/03/javascript-non-primitive-data-type-example-324x268.png 324w, https://careersknowledge.in/wp-content/uploads/2024/03/javascript-non-primitive-data-type-example-300x248.png 300w" sizes="auto, (max-width: 714px) 100vw, 714px" /></p>
<p><strong><span style="color: #000000;">Also Check Our Latest Upload </span></strong></p>
<p><a href="https://careersknowledge.in/javascript-innerhtml-document-write-window-alert/">JavaScript innerHTML document.write() window.alert()</a></p>
<p><a href="https://careersknowledge.in/javascript-variables-and-data-types/">javascript variables and data types</a></p>
<p><a href="https://careersknowledge.in/concept-of-javascript/">concept of JavaScript?</a></p>
<p>The post <a href="https://careersknowledge.in/what-are-the-javascript-data-types/">What are the JavaScript data types</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/what-are-the-javascript-data-types/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaScript innerHTML document.write() window.alert()</title>
		<link>https://careersknowledge.in/javascript-innerhtml-document-write-window-alert/</link>
					<comments>https://careersknowledge.in/javascript-innerhtml-document-write-window-alert/#comments</comments>
		
		<dc:creator><![CDATA[Shubham Laxakar]]></dc:creator>
		<pubDate>Thu, 28 Mar 2024 14:22:40 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[javascript document.write]]></category>
		<category><![CDATA[javascript window.print]]></category>
		<category><![CDATA[javascript window.print page setup]]></category>
		<category><![CDATA[What is innerText in JavaScript?]]></category>
		<category><![CDATA[What is the difference between window prompt and window alert in JavaScript?]]></category>
		<category><![CDATA[What is window alert in JavaScript?]]></category>
		<guid isPermaLink="false">https://careersknowledge.in/?p=1419</guid>

					<description><![CDATA[<p>JavaScript innerHTML document.write() window.alert() In this Blog You will learn about the JavaScript innerHTML document.write() window.alert(). Here you will learn all these methods with examples. So Must check the full Article.  JavaScript Display Possibilities JavaScript can &#8220;display&#8221; data in different ways: Writing into an HTML element, using innerHTML. Writing into the HTML output using write(). ... <a title="JavaScript innerHTML document.write() window.alert()" class="read-more" href="https://careersknowledge.in/javascript-innerhtml-document-write-window-alert/" aria-label="Read more about JavaScript innerHTML document.write() window.alert()">Read more</a></p>
<p>The post <a href="https://careersknowledge.in/javascript-innerhtml-document-write-window-alert/">JavaScript innerHTML document.write() window.alert()</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1 style="text-align: center;"><strong><span style="color: #000000;">JavaScript innerHTML document.write() window.alert()</span></strong></h1>
<p><span style="color: #000000;">In this Blog You will learn about the JavaScript innerHTML document.write() window.alert(). Here you will learn all these methods with examples. So Must check the full Article. </span></p>
<h3><strong><span style="color: #000000;">JavaScript Display Possibilities</span></strong></h3>
<p><span style="color: #000000;">JavaScript can &#8220;display&#8221; data in different ways:</span></p>
<ul>
<li><span style="color: #000000;">Writing into an HTML element, using innerHTML.</span></li>
<li><span style="color: #000000;">Writing into the HTML output using write().</span></li>
<li><span style="color: #000000;">Writing into an alert box, using alert().</span></li>
</ul>
<h3 style="text-align: center;"><span style="color: #000000;"><strong>Using innerHTML</strong></span></h3>
<p><span style="color: #000000;">To access an HTML element, JavaScript can usethe document.getElementById(id) method.The id attribute defines the HTML element. The innerHTML property defines the HTML content:</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;My First Web Page&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;p&gt;My First Paragraph&lt;/p&gt;</span><br />
<span style="color: #000000;">&lt;p id=&#8221;demo&#8221;&gt;&lt;/p&gt;</span><br />
<span style="color: #000000;">&lt;script&gt; document.getElementById(&#8220;demo&#8221;).innerHTML = 15 + 6;</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1427" src="http://careersknowledge.in/wp-content/uploads/2024/03/innerhtml.png" alt="" width="642" height="277" srcset="https://careersknowledge.in/wp-content/uploads/2024/03/innerhtml.png 642w, https://careersknowledge.in/wp-content/uploads/2024/03/innerhtml-324x140.png 324w, https://careersknowledge.in/wp-content/uploads/2024/03/innerhtml-300x129.png 300w" sizes="auto, (max-width: 642px) 100vw, 642px" /></span></p>
<p>&nbsp;</p>
<p>Subscribe Our Youtube Channel For Live Class link is given below-</p>
<p><a href="https://www.youtube.com/@olevelguruji">https://www.youtube.com/@olevelguruji</a></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">Using document.write()</span></strong></h3>
<p><span style="color: #000000;">For testing purposes, it is convenient to use document.write():</span></p>
<p><span style="color: #000000;">Example</span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;My First Web Page&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;p&gt;My first paragraph.&lt;/p&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">document.write(&#8220;This is document.write() function example&lt;br&gt;&#8221;);</span><br />
<span style="color: #000000;">document.write(&#8220;Addition of 55+6 is &#8221; +(55+ 6));</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1428 size-full" src="http://careersknowledge.in/wp-content/uploads/2024/03/documentwritefunction.png" alt="JavaScript innerHTML document.write() window.alert()" width="527" height="298" srcset="https://careersknowledge.in/wp-content/uploads/2024/03/documentwritefunction.png 527w, https://careersknowledge.in/wp-content/uploads/2024/03/documentwritefunction-324x183.png 324w, https://careersknowledge.in/wp-content/uploads/2024/03/documentwritefunction-300x170.png 300w" sizes="auto, (max-width: 527px) 100vw, 527px" /></span></p>
<p><span style="color: #000000;">&lt;html&gt;</span></p>
<p><span style="color: #000000;">&lt;body&gt;</span></p>
<p><span style="color: #000000;">&lt;h1&gt;My First Web Page&lt;/h1&gt;</span></p>
<p><span style="color: #000000;">&lt;p&gt;My first paragraph.&lt;/p&gt;</span></p>
<p><span style="color: #000000;">&lt;button type=&#8221;button&#8221; onclick=&#8221;document.write(5 + 6)&#8221;&gt;Try it&lt;/button&gt;</span></p>
<p><span style="color: #000000;">&lt;/body&gt;</span></p>
<p><span style="color: #000000;">&lt;/html&gt;</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">Using window.alert()</span></strong></h3>
<p><span style="color: #000000;">You can use an alert box to display data:</span></p>
<h5><span style="color: #000000;">Example</span></h5>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;h1&gt;My First Web Page&lt;/h1&gt;</span><br />
<span style="color: #000000;">&lt;p&gt;My first paragraph.&lt;/p&gt;</span><br />
<span style="color: #000000;">&lt;script&gt;</span><br />
<span style="color: #000000;">window.alert(55 + 65);</span><br />
<span style="color: #000000;">&lt;/script&gt;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;">Output</span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1431 size-large" src="http://careersknowledge.in/wp-content/uploads/2024/03/windowalert-1024x205.png" alt="JavaScript innerHTML document.write() window.alert()" width="1024" height="205" srcset="https://careersknowledge.in/wp-content/uploads/2024/03/windowalert-1024x205.png 1024w, https://careersknowledge.in/wp-content/uploads/2024/03/windowalert-324x65.png 324w, https://careersknowledge.in/wp-content/uploads/2024/03/windowalert-300x60.png 300w, https://careersknowledge.in/wp-content/uploads/2024/03/windowalert-768x154.png 768w, https://careersknowledge.in/wp-content/uploads/2024/03/windowalert.png 1285w" sizes="auto, (max-width: 1024px) 100vw, 1024px" />You can skip the window keyword.</span></p>
<p><span style="color: #000000;">In JavaScript, the window object is the global scope object, that means that variables, properties, and methods by default belong to the window object. This also means that specifying the window keyword is optional:</span></p>
<h3 style="text-align: center;"><strong><span style="color: #000000;">JavaScript Print</span></strong></h3>
<p><span style="color: #000000;">JavaScript does not have any print object or print methods. You cannot access output devices from JavaScript.</span></p>
<p><span style="color: #000000;">The only exception is that you can call the window.print() method in the browser to print the content of the current window.</span></p>
<p><span style="color: #000000;">Example</span></p>
<p><span style="color: #000000;">&lt;html&gt;</span><br />
<span style="color: #000000;">&lt;body&gt;</span><br />
<span style="color: #000000;">&lt;button onclick=&#8221;window.print()&#8221;&gt;Print this page&lt;/button&gt;&lt;br&gt;</span><br />
<span style="color: #000000;">welcome to window.print() method in javascript&#8230;</span><br />
<span style="color: #000000;">&lt;/body&gt;</span><br />
<span style="color: #000000;">&lt;/html&gt;</span></p>
<p><span style="color: #000000;"><strong>Output</strong></span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1432" src="http://careersknowledge.in/wp-content/uploads/2024/03/windowprint.png" alt="" width="849" height="288" srcset="https://careersknowledge.in/wp-content/uploads/2024/03/windowprint.png 849w, https://careersknowledge.in/wp-content/uploads/2024/03/windowprint-324x110.png 324w, https://careersknowledge.in/wp-content/uploads/2024/03/windowprint-300x102.png 300w, https://careersknowledge.in/wp-content/uploads/2024/03/windowprint-768x261.png 768w" sizes="auto, (max-width: 849px) 100vw, 849px" /></span></p>
<p><span style="color: #000000;">When we click on the Print this page button then you will get the Output</span></p>
<p><span style="color: #000000;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1433 size-large" src="http://careersknowledge.in/wp-content/uploads/2024/03/windowprintmethod-1024x490.png" alt="JavaScript innerHTML document.write() window.alert()" width="1024" height="490" srcset="https://careersknowledge.in/wp-content/uploads/2024/03/windowprintmethod-1024x490.png 1024w, https://careersknowledge.in/wp-content/uploads/2024/03/windowprintmethod-324x155.png 324w, https://careersknowledge.in/wp-content/uploads/2024/03/windowprintmethod-300x144.png 300w, https://careersknowledge.in/wp-content/uploads/2024/03/windowprintmethod-768x368.png 768w, https://careersknowledge.in/wp-content/uploads/2024/03/windowprintmethod.png 1280w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></span></p>
<p><span style="color: #000000;"><strong>Also Check Our Latest Uploads</strong></span></p>
<p><a href="https://careersknowledge.in/javascript-variables-and-data-types/">javascript variables and data types</a></p>
<p><a href="https://careersknowledge.in/concept-of-javascript/">concept of JavaScript?</a></p>
<p><a href="https://careersknowledge.in/client-side-scripting-language-and-server-side-scripting/">client-side scripting language and server-side scripting</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://careersknowledge.in/javascript-innerhtml-document-write-window-alert/">JavaScript innerHTML document.write() window.alert()</a> appeared first on <a href="https://careersknowledge.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://careersknowledge.in/javascript-innerhtml-document-write-window-alert/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
