{"id":567,"date":"2025-05-19T10:50:44","date_gmt":"2025-05-19T10:50:44","guid":{"rendered":"https:\/\/buhave.com\/courses\/?p=567"},"modified":"2025-05-20T12:57:38","modified_gmt":"2025-05-20T12:57:38","slug":"real-world-applications","status":"publish","type":"post","link":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/","title":{"rendered":"Real-World Applications"},"content":{"rendered":"<h2>Build an interactive to-do list<span style=\"font-weight: 400\"><br \/>\n<\/span><\/h2>\n<h3>1. HTML Structure<\/h3>\n<p>The HTML will consist of the basic layout for the to-do list. We\u2019ll need an input field, a button to add new tasks, and a list to display the tasks.<\/p>\n<p style=\"text-align: center\"><em>&lt;!DOCTYPE html&gt;<\/em><br \/>\n<em>&lt;html lang=&#8221;en&#8221;&gt;<\/em><br \/>\n<em>&lt;head&gt;<\/em><br \/>\n<em>&lt;meta charset=&#8221;UTF-8&#8243;&gt;<\/em><br \/>\n<em>&lt;meta name=&#8221;viewport&#8221; content=&#8221;width=device-width, initial-scale=1.0&#8243;&gt;<\/em><br \/>\n<em>&lt;title&gt;To-Do List&lt;\/title&gt;<\/em><br \/>\n<em>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;styles.css&#8221;&gt;<\/em><br \/>\n<em>&lt;\/head&gt;<\/em><br \/>\n<em>&lt;body&gt;<\/em><br \/>\n<em>&lt;div class=&#8221;todo-container&#8221;&gt;<\/em><br \/>\n<em>&lt;h1&gt;My To-Do List&lt;\/h1&gt;<\/em><br \/>\n<em>&lt;input type=&#8221;text&#8221; id=&#8221;taskInput&#8221; placeholder=&#8221;Enter a new task&#8221;&gt;<\/em><br \/>\n<em>&lt;button id=&#8221;addTaskButton&#8221;&gt;Add Task&lt;\/button&gt;<\/em><br \/>\n<em>&lt;ul id=&#8221;taskList&#8221;&gt;&lt;\/ul&gt;<\/em><br \/>\n<em>&lt;\/div&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;script src=&#8221;script.js&#8221;&gt;&lt;\/script&gt;<\/em><br \/>\n<em>&lt;\/body&gt;<\/em><br \/>\n<em>&lt;\/html&gt;<\/em><\/p>\n<h3>2. CSS Styling<\/h3>\n<p>The CSS will style the to-do list, making it visually appealing.<\/p>\n<p style=\"text-align: center\"><em>\/* styles.css *\/<\/em><br \/>\n<em>body {<\/em><br \/>\n<em>font-family: Arial, sans-serif;<\/em><br \/>\n<em>background-color: #f4f4f9;<\/em><br \/>\n<em>display: flex;<\/em><br \/>\n<em>justify-content: center;<\/em><br \/>\n<em>align-items: center;<\/em><br \/>\n<em>height: 100vh;<\/em><br \/>\n<em>margin: 0;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>.todo-container {<\/em><br \/>\n<em>background-color: #fff;<\/em><br \/>\n<em>padding: 20px;<\/em><br \/>\n<em>box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);<\/em><br \/>\n<em>border-radius: 8px;<\/em><br \/>\n<em>width: 300px;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>h1 {<\/em><br \/>\n<em>text-align: center;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>input, button {<\/em><br \/>\n<em>width: 100%;<\/em><br \/>\n<em>padding: 10px;<\/em><br \/>\n<em>margin: 5px 0;<\/em><br \/>\n<em>border: 1px solid #ccc;<\/em><br \/>\n<em>border-radius: 4px;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>button {<\/em><br \/>\n<em>background-color: #4CAF50;<\/em><br \/>\n<em>color: white;<\/em><br \/>\n<em>border: none;<\/em><br \/>\n<em>cursor: pointer;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>button:hover {<\/em><br \/>\n<em>background-color: #45a049;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>ul {<\/em><br \/>\n<em>list-style-type: none;<\/em><br \/>\n<em>padding-left: 0;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>li {<\/em><br \/>\n<em>background-color: #f1f1f1;<\/em><br \/>\n<em>margin: 5px 0;<\/em><br \/>\n<em>padding: 10px;<\/em><br \/>\n<em>border-radius: 4px;<\/em><br \/>\n<em>display: flex;<\/em><br \/>\n<em>justify-content: space-between;<\/em><br \/>\n<em>align-items: center;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>li.done {<\/em><br \/>\n<em>text-decoration: line-through;<\/em><br \/>\n<em>color: #888;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>.delete {<\/em><br \/>\n<em>background-color: #ff4d4d;<\/em><br \/>\n<em>color: white;<\/em><br \/>\n<em>border: none;<\/em><br \/>\n<em>border-radius: 4px;<\/em><br \/>\n<em>padding: 5px;<\/em><br \/>\n<em>cursor: pointer;<\/em><br \/>\n<em>}<\/em><\/p>\n<h3>3. JavaScript Functionality<\/h3>\n<p>Now, let\u2019s implement the functionality to add tasks, mark them as complete, and delete tasks.<\/p>\n<p style=\"text-align: center\"><em>\/\/ script.js<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Get references to DOM elements<\/em><br \/>\n<em>const taskInput = document.getElementById(&#8216;taskInput&#8217;);<\/em><br \/>\n<em>const addTaskButton = document.getElementById(&#8216;addTaskButton&#8217;);<\/em><br \/>\n<em>const taskList = document.getElementById(&#8216;taskList&#8217;);<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Function to create a new task item<\/em><br \/>\n<em>function createTask(taskContent) {<\/em><br \/>\n<em>\/\/ Create list item<\/em><br \/>\n<em>const taskItem = document.createElement(&#8216;li&#8217;);<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Create a text node for the task content<\/em><br \/>\n<em>const taskText = document.createElement(&#8216;span&#8217;);<\/em><br \/>\n<em>taskText.textContent = taskContent;<\/em><br \/>\n<em>taskItem.appendChild(taskText);<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Create a delete button<\/em><br \/>\n<em>const deleteButton = document.createElement(&#8216;button&#8217;);<\/em><br \/>\n<em>deleteButton.textContent = &#8216;Delete&#8217;;<\/em><br \/>\n<em>deleteButton.classList.add(&#8216;delete&#8217;);<\/em><br \/>\n<em>taskItem.appendChild(deleteButton);<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Append the task item to the task list<\/em><br \/>\n<em>taskList.appendChild(taskItem);<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Mark task as done when clicked<\/em><br \/>\n<em>taskItem.addEventListener(&#8216;click&#8217;, () =&gt; {<\/em><br \/>\n<em>taskItem.classList.toggle(&#8216;done&#8217;);<\/em><br \/>\n<em>});<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Delete task when delete button is clicked<\/em><br \/>\n<em>deleteButton.addEventListener(&#8216;click&#8217;, (event) =&gt; {<\/em><br \/>\n<em>event.stopPropagation(); \/\/ Prevent the click event from propagating to taskItem<\/em><br \/>\n<em>taskList.removeChild(taskItem);<\/em><br \/>\n<em>});<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Add task when the button is clicked<\/em><br \/>\n<em>addTaskButton.addEventListener(&#8216;click&#8217;, () =&gt; {<\/em><br \/>\n<em>const taskContent = taskInput.value.trim();<\/em><\/p>\n<p style=\"text-align: center\"><em>if (taskContent) {<\/em><br \/>\n<em>createTask(taskContent);<\/em><br \/>\n<em>taskInput.value = &#8221;; \/\/ Clear the input field<\/em><br \/>\n<em>}<\/em><br \/>\n<em>});<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Optionally, allow the user to press Enter to add a task<\/em><br \/>\n<em>taskInput.addEventListener(&#8216;keypress&#8217;, (event) =&gt; {<\/em><br \/>\n<em>if (event.key === &#8216;Enter&#8217;) {<\/em><br \/>\n<em>addTaskButton.click();<\/em><br \/>\n<em>}<\/em><br \/>\n<em>});<\/em><\/p>\n<h3>4. How It Works:<\/h3>\n<ul>\n<li>HTML: We set up the basic structure for the to-do list, including an input field for entering tasks, a button to add tasks, and a list to display them.<\/li>\n<li>CSS: Provides a simple yet attractive design. Tasks are styled with a background color, padding, and margins. We also added hover effects and styles for completed tasks.<\/li>\n<li>JavaScript: The script manages the core functionality:<\/li>\n<li>Adding tasks: When the &#8220;Add Task&#8221; button is clicked or Enter is pressed, the task is added to the list.<\/li>\n<li>Marking tasks as complete: Clicking on a task toggles its completion, applying a line-through effect.<\/li>\n<li>Deleting tasks: The &#8220;Delete&#8221; button beside each task allows the user to remove the task from the list.<\/li>\n<\/ul>\n<h3>5. Improvement Ideas:<\/h3>\n<ul>\n<li>Persistent Storage: Save the tasks to localStorage so they persist after refreshing the page.<\/li>\n<li>Editing Tasks: Allow users to edit task content after it has been added.<\/li>\n<li>Styling Enhancements: Add icons or animations to improve the UX.<\/li>\n<\/ul>\n<p><strong>Recap:<\/strong><\/p>\n<p>You\u2019ve now built a functional interactive to-do list that allows users to:<\/p>\n<ul>\n<li>Add tasks<\/li>\n<li>Mark tasks as complete<\/li>\n<li>Delete tasks<\/li>\n<\/ul>\n<p>This is a great starting point for learning about JavaScript event handling, DOM manipulation, and user interactions.<\/p>\n<h2>Form Validation<\/h2>\n<p>Form validation is an essential process to ensure that the data submitted by the user is in the correct format and meets the expected criteria. It can be done both on the client-side (using JavaScript) and server-side (on the server after the form is submitted). Here, we&#8217;ll focus on client-side form validation using JavaScript.<\/p>\n<h3>1. Basic Form Structure (HTML)<\/h3>\n<p>Here is an example of a simple form that asks for the user\u2019s name, email, and password.<\/p>\n<p style=\"text-align: center\"><em>&lt;!DOCTYPE html&gt;<\/em><br \/>\n<em>&lt;html lang=&#8221;en&#8221;&gt;<\/em><br \/>\n<em>&lt;head&gt;<\/em><br \/>\n<em>&lt;meta charset=&#8221;UTF-8&#8243;&gt;<\/em><br \/>\n<em>&lt;meta name=&#8221;viewport&#8221; content=&#8221;width=device-width, initial-scale=1.0&#8243;&gt;<\/em><br \/>\n<em>&lt;title&gt;Form Validation&lt;\/title&gt;<\/em><br \/>\n<em>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;styles.css&#8221;&gt;<\/em><br \/>\n<em>&lt;\/head&gt;<\/em><br \/>\n<em>&lt;body&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;div class=&#8221;form-container&#8221;&gt;<\/em><br \/>\n<em>&lt;h2&gt;Sign Up Form&lt;\/h2&gt;<\/em><br \/>\n<em>&lt;form id=&#8221;signupForm&#8221;&gt;<\/em><br \/>\n<em>&lt;label for=&#8221;name&#8221;&gt;Name:&lt;\/label&gt;<\/em><br \/>\n<em>&lt;input type=&#8221;text&#8221; id=&#8221;name&#8221; name=&#8221;name&#8221; required&gt;<\/em><br \/>\n<em>&lt;span class=&#8221;error&#8221; id=&#8221;nameError&#8221;&gt;&lt;\/span&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;label for=&#8221;email&#8221;&gt;Email:&lt;\/label&gt;<\/em><br \/>\n<em>&lt;input type=&#8221;email&#8221; id=&#8221;email&#8221; name=&#8221;email&#8221; required&gt;<\/em><br \/>\n<em>&lt;span class=&#8221;error&#8221; id=&#8221;emailError&#8221;&gt;&lt;\/span&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;label for=&#8221;password&#8221;&gt;Password:&lt;\/label&gt;<\/em><br \/>\n<em>&lt;input type=&#8221;password&#8221; id=&#8221;password&#8221; name=&#8221;password&#8221; required&gt;<\/em><br \/>\n<em>&lt;span class=&#8221;error&#8221; id=&#8221;passwordError&#8221;&gt;&lt;\/span&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;button type=&#8221;submit&#8221;&gt;Submit&lt;\/button&gt;<\/em><br \/>\n<em>&lt;\/form&gt;<\/em><br \/>\n<em>&lt;\/div&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;script src=&#8221;script.js&#8221;&gt;&lt;\/script&gt;<\/em><br \/>\n<em>&lt;\/body&gt;<\/em><br \/>\n<em>&lt;\/html&gt;<\/em><\/p>\n<h3>2. Basic CSS Styling<\/h3>\n<p>We will style the form and error messages to make them more visually distinct.<\/p>\n<p style=\"text-align: center\"><em>\/* styles.css *\/<\/em><br \/>\n<em>body {<\/em><br \/>\n<em>font-family: Arial, sans-serif;<\/em><br \/>\n<em>background-color: #f8f9fa;<\/em><br \/>\n<em>display: flex;<\/em><br \/>\n<em>justify-content: center;<\/em><br \/>\n<em>align-items: center;<\/em><br \/>\n<em>height: 100vh;<\/em><br \/>\n<em>margin: 0;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>.form-container {<\/em><br \/>\n<em>background-color: #fff;<\/em><br \/>\n<em>padding: 20px;<\/em><br \/>\n<em>box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);<\/em><br \/>\n<em>width: 300px;<\/em><br \/>\n<em>border-radius: 8px;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>h2 {<\/em><br \/>\n<em>text-align: center;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>label {<\/em><br \/>\n<em>display: block;<\/em><br \/>\n<em>margin: 10px 0 5px;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>input {<\/em><br \/>\n<em>width: 100%;<\/em><br \/>\n<em>padding: 10px;<\/em><br \/>\n<em>margin-bottom: 15px;<\/em><br \/>\n<em>border: 1px solid #ccc;<\/em><br \/>\n<em>border-radius: 4px;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>button {<\/em><br \/>\n<em>background-color: #4CAF50;<\/em><br \/>\n<em>color: white;<\/em><br \/>\n<em>width: 100%;<\/em><br \/>\n<em>padding: 10px;<\/em><br \/>\n<em>border: none;<\/em><br \/>\n<em>border-radius: 4px;<\/em><br \/>\n<em>cursor: pointer;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>button:hover {<\/em><br \/>\n<em>background-color: #45a049;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>.error {<\/em><br \/>\n<em>color: red;<\/em><br \/>\n<em>font-size: 12px;<\/em><br \/>\n<em>}<\/em><\/p>\n<h3>3. JavaScript for Form Validation<\/h3>\n<p>Now, let\u2019s implement JavaScript to validate the form before submission.<\/p>\n<p style=\"text-align: center\"><em>\/\/ script.js<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Get form and input elements<\/em><br \/>\n<em>const form = document.getElementById(&#8216;signupForm&#8217;);<\/em><br \/>\n<em>const nameInput = document.getElementById(&#8216;name&#8217;);<\/em><br \/>\n<em>const emailInput = document.getElementById(&#8217;email&#8217;);<\/em><br \/>\n<em>const passwordInput = document.getElementById(&#8216;password&#8217;);<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Get error display elements<\/em><br \/>\n<em>const nameError = document.getElementById(&#8216;nameError&#8217;);<\/em><br \/>\n<em>const emailError = document.getElementById(&#8217;emailError&#8217;);<\/em><br \/>\n<em>const passwordError = document.getElementById(&#8216;passwordError&#8217;);<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Validate name<\/em><br \/>\n<em>function validateName() {<\/em><br \/>\n<em>if (nameInput.value.trim() === &#8221;) {<\/em><br \/>\n<em>nameError.textContent = &#8216;Name is required.&#8217;;<\/em><br \/>\n<em>return false;<\/em><br \/>\n<em>} else {<\/em><br \/>\n<em>nameError.textContent = &#8221;;<\/em><br \/>\n<em>return true;<\/em><br \/>\n<em>}<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Validate email using regular expression (Regex)<\/em><br \/>\n<em>function validateEmail() {<\/em><br \/>\n<em>const emailPattern = \/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$\/;<\/em><br \/>\n<em>if (!emailPattern.test(emailInput.value)) {<\/em><br \/>\n<em>emailError.textContent = &#8216;Please enter a valid email address.&#8217;;<\/em><br \/>\n<em>return false;<\/em><br \/>\n<em>} else {<\/em><br \/>\n<em>emailError.textContent = &#8221;;<\/em><br \/>\n<em>return true;<\/em><br \/>\n<em>}<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Validate password (min 8 characters)<\/em><br \/>\n<em>function validatePassword() {<\/em><br \/>\n<em>if (passwordInput.value.length &lt; 8) {<\/em><br \/>\n<em>passwordError.textContent = &#8216;Password must be at least 8 characters long.&#8217;;<\/em><br \/>\n<em>return false;<\/em><br \/>\n<em>} else {<\/em><br \/>\n<em>passwordError.textContent = &#8221;;<\/em><br \/>\n<em>return true;<\/em><br \/>\n<em>}<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Form submission handler<\/em><br \/>\n<em>form.addEventListener(&#8216;submit&#8217;, function(event) {<\/em><br \/>\n<em>\/\/ Prevent form submission if any field is invalid<\/em><br \/>\n<em>event.preventDefault();<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Validate all fields<\/em><br \/>\n<em>const isNameValid = validateName();<\/em><br \/>\n<em>const isEmailValid = validateEmail();<\/em><br \/>\n<em>const isPasswordValid = validatePassword();<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ If all fields are valid, submit the form<\/em><br \/>\n<em>if (isNameValid &amp;&amp; isEmailValid &amp;&amp; isPasswordValid) {<\/em><br \/>\n<em>alert(&#8216;Form submitted successfully!&#8217;);<\/em><br \/>\n<em>form.reset(); \/\/ Reset form fields<\/em><br \/>\n<em>}<\/em><br \/>\n<em>});<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Event listeners for real-time validation<\/em><br \/>\n<em>nameInput.addEventListener(&#8216;input&#8217;, validateName);<\/em><br \/>\n<em>emailInput.addEventListener(&#8216;input&#8217;, validateEmail);<\/em><br \/>\n<em>passwordInput.addEventListener(&#8216;input&#8217;, validatePassword);<\/em><\/p>\n<h3>4. How the Validation Works:<\/h3>\n<p><strong>1. Validate Name:<\/strong><\/p>\n<ul>\n<li>If the name field is empty, an error message will appear saying &#8220;Name is required.&#8221;<\/li>\n<\/ul>\n<p><strong>2. Validate Email:<\/strong><\/p>\n<ul>\n<li>Uses a regular expression to ensure the email is in a valid format (e.g., someone@example.com).<\/li>\n<\/ul>\n<p><strong>3. Validate Password:<\/strong><\/p>\n<ul>\n<li>Checks if the password is at least 8 characters long. If not, an error message will prompt the user.<\/li>\n<\/ul>\n<p><strong>4. Form Submission:<\/strong><\/p>\n<p>When the form is submitted, we prevent its default action (actual submission) using event.preventDefault(). Then, each field is validated, and if any validation fails, the corresponding error message is shown. Only if all fields are valid will the form be submitted (or we show a success alert in this case).<\/p>\n<h3>5. Additional Validation Tips:<\/h3>\n<ul>\n<li>Client-Side vs Server-Side Validation: While client-side validation enhances user experience by catching errors before submission, server-side validation is still critical for security, as users can bypass client-side checks.<\/li>\n<li>Real-time Feedback: As seen in this example, real-time validation (while the user is typing) improves user experience by guiding them immediately when they enter incorrect data.<\/li>\n<li>Regex: Regular expressions are powerful for validating emails, phone numbers, and more. You can find more complex patterns for various use cases.<\/li>\n<\/ul>\n<p><strong>Recap:<\/strong><\/p>\n<ul>\n<li>You\u2019ve now built a simple form validation system that:<\/li>\n<li>Validates user input for Name, Email, and Password.<\/li>\n<li>Provides real-time and on-submit error messages.<\/li>\n<li>Prevents form submission if the data is invalid.<\/li>\n<li>This basic setup can be extended with additional features like:<\/li>\n<li>Confirm password field for matching.<\/li>\n<li>Password strength validation (e.g., include uppercase, numbers).<\/li>\n<li>More complex error handling (e.g., AJAX error responses).<\/li>\n<\/ul>\n<h2>Simple Calculator<\/h2>\n<p>A simple calculator allows users to perform basic arithmetic operations like addition, subtraction, multiplication, and division. It takes input from users, processes the operation when buttons are clicked, and displays the result.<\/p>\n<h3>1. Basic HTML Structure<\/h3>\n<p><strong>Create the interface:<\/strong> display screen and buttons.<\/p>\n<p style=\"text-align: center\"><em>&lt;!DOCTYPE html&gt;<\/em><br \/>\n<em>&lt;html lang=&#8221;en&#8221;&gt;<\/em><br \/>\n<em>&lt;head&gt;<\/em><br \/>\n<em>&lt;meta charset=&#8221;UTF-8&#8243;&gt;<\/em><br \/>\n<em>&lt;meta name=&#8221;viewport&#8221; content=&#8221;width=device-width, initial-scale=1&#8243;&gt;<\/em><br \/>\n<em>&lt;title&gt;Simple Calculator&lt;\/title&gt;<\/em><br \/>\n<em>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;style.css&#8221;&gt;<\/em><br \/>\n<em>&lt;\/head&gt;<\/em><br \/>\n<em>&lt;body&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;div class=&#8221;calculator&#8221;&gt;<\/em><br \/>\n<em>&lt;input type=&#8221;text&#8221; id=&#8221;display&#8221; disabled&gt;<\/em><br \/>\n<em>&lt;div class=&#8221;buttons&#8221;&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;clearDisplay()&#8221;&gt;C&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;\/&#8217;)&#8221;&gt;\/&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;*&#8217;)&#8221;&gt;*&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;deleteLast()&#8221;&gt;\u232b&lt;\/button&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;button onclick=&#8221;appendCharacter(&#8216;7&#8217;)&#8221;&gt;7&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;8&#8217;)&#8221;&gt;8&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;9&#8217;)&#8221;&gt;9&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;-&#8216;)&#8221;&gt;-&lt;\/button&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;button onclick=&#8221;appendCharacter(&#8216;4&#8217;)&#8221;&gt;4&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;5&#8217;)&#8221;&gt;5&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;6&#8217;)&#8221;&gt;6&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;+&#8217;)&#8221;&gt;+&lt;\/button&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;button onclick=&#8221;appendCharacter(&#8216;1&#8217;)&#8221;&gt;1&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;2&#8217;)&#8221;&gt;2&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;3&#8217;)&#8221;&gt;3&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;calculate()&#8221;&gt;=&lt;\/button&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;button onclick=&#8221;appendCharacter(&#8216;0&#8217;)&#8221; class=&#8221;zero&#8221;&gt;0&lt;\/button&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;appendCharacter(&#8216;.&#8217;)&#8221;&gt;.&lt;\/button&gt;<\/em><br \/>\n<em>&lt;\/div&gt;<\/em><br \/>\n<em>&lt;\/div&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;script src=&#8221;script.js&#8221;&gt;&lt;\/script&gt;<\/em><br \/>\n<em>&lt;\/body&gt;<\/em><br \/>\n<em>&lt;\/html&gt;<\/em><\/p>\n<h3>2. Basic CSS Styling<\/h3>\n<p>Simple styling for layout and visual design.<\/p>\n<p style=\"text-align: center\"><em>\/* style.css *\/<\/em><br \/>\n<em>body {<\/em><br \/>\n<em>display: flex;<\/em><br \/>\n<em>justify-content: center;<\/em><br \/>\n<em>align-items: center;<\/em><br \/>\n<em>height: 100vh;<\/em><br \/>\n<em>background: #e3f2fd;<\/em><br \/>\n<em>margin: 0;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>.calculator {<\/em><br \/>\n<em>background: #fff;<\/em><br \/>\n<em>padding: 20px;<\/em><br \/>\n<em>border-radius: 15px;<\/em><br \/>\n<em>box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>#display {<\/em><br \/>\n<em>width: 100%;<\/em><br \/>\n<em>height: 50px;<\/em><br \/>\n<em>margin-bottom: 10px;<\/em><br \/>\n<em>text-align: right;<\/em><br \/>\n<em>font-size: 1.5rem;<\/em><br \/>\n<em>padding: 10px;<\/em><br \/>\n<em>border: 1px solid #ccc;<\/em><br \/>\n<em>border-radius: 8px;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>.buttons {<\/em><br \/>\n<em>display: grid;<\/em><br \/>\n<em>grid-template-columns: repeat(4, 70px);<\/em><br \/>\n<em>gap: 10px;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>button {<\/em><br \/>\n<em>padding: 15px;<\/em><br \/>\n<em>font-size: 1.2rem;<\/em><br \/>\n<em>border: none;<\/em><br \/>\n<em>background-color: #90caf9;<\/em><br \/>\n<em>border-radius: 8px;<\/em><br \/>\n<em>cursor: pointer;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>button:hover {<\/em><br \/>\n<em>background-color: #64b5f6;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>.zero {<\/em><br \/>\n<em>grid-column: span 2;<\/em><br \/>\n<em>}<\/em><\/p>\n<h3>3. JavaScript for Calculator Logic<\/h3>\n<p>The code handles button clicks, operations, and results.<\/p>\n<p style=\"text-align: center\"><em>\/\/ script.js<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Get the display element<\/em><br \/>\n<em>const display = document.getElementById(&#8216;display&#8217;);<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Function to append a character (number\/operator)<\/em><br \/>\n<em>function appendCharacter(character) {<\/em><br \/>\n<em>display.value += character;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Function to clear the display<\/em><br \/>\n<em>function clearDisplay() {<\/em><br \/>\n<em>display.value = &#8221;;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Function to delete the last character<\/em><br \/>\n<em>function deleteLast() {<\/em><br \/>\n<em>display.value = display.value.slice(0, -1);<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>\/\/ Function to calculate the result<\/em><br \/>\n<em>function calculate() {<\/em><br \/>\n<em>try {<\/em><br \/>\n<em>display.value = eval(display.value);<\/em><br \/>\n<em>} catch (error) {<\/em><br \/>\n<em>alert(&#8216;Invalid Expression&#8217;);<\/em><br \/>\n<em>}<\/em><br \/>\n<em>}<\/em><\/p>\n<h3>4. How This Calculator Works<\/h3>\n<ul>\n<li>Display (input): Shows the current expression or result.<\/li>\n<li>Button Clicks: Numbers and operators are appended to the display.<\/li>\n<li>Clear (C): Empties the display completely.<\/li>\n<li>Backspace (\u232b): Deletes the last character from the display.<\/li>\n<li>Equals (=): Evaluates the full mathematical expression using eval() and shows the result.<\/li>\n<li>Error Handling: If the expression is invalid (e.g., wrong syntax), an alert appears.<\/li>\n<\/ul>\n<h3>5. Important Notes<\/h3>\n<ul>\n<li>Eval() is easy but not safe for real-world apps (it executes any JavaScript code).<\/li>\n<li>In production, it&#8217;s better to parse and evaluate the expression manually or use a library.<\/li>\n<li>Always validate input if you extend this calculator!<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<ul>\n<li>Click 5<\/li>\n<li>Click +<\/li>\n<li>Click 7<\/li>\n<li>Click =<\/li>\n<li>Output \u2192 12<\/li>\n<\/ul>\n<h2>Weather app using API<\/h2>\n<p>A Weather App allows users to input a city name and fetch real-time weather data (like temperature, condition, humidity) from a public API (like OpenWeatherMap) and display it cleanly.<\/p>\n<h3>1. Setup: Basic HTML Structure<\/h3>\n<p>Create a simple input field, search button, and an area to show weather information.<\/p>\n<p style=\"text-align: center\"><em>&lt;!DOCTYPE html&gt;<\/em><br \/>\n<em>&lt;html lang=&#8221;en&#8221;&gt;<\/em><br \/>\n<em>&lt;head&gt;<\/em><br \/>\n<em>&lt;meta charset=&#8221;UTF-8&#8243;&gt;<\/em><br \/>\n<em>&lt;meta name=&#8221;viewport&#8221; content=&#8221;width=device-width, initial-scale=1&#8243;&gt;<\/em><br \/>\n<em>&lt;title&gt;Weather App&lt;\/title&gt;<\/em><br \/>\n<em>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;style.css&#8221;&gt;<\/em><br \/>\n<em>&lt;\/head&gt;<\/em><br \/>\n<em>&lt;body&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;div class=&#8221;weather-app&#8221;&gt;<\/em><br \/>\n<em>&lt;h1&gt;Weather Checker&lt;\/h1&gt;<\/em><br \/>\n<em>&lt;input type=&#8221;text&#8221; id=&#8221;cityInput&#8221; placeholder=&#8221;Enter city name&#8221;&gt;<\/em><br \/>\n<em>&lt;button onclick=&#8221;getWeather()&#8221;&gt;Search&lt;\/button&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;div class=&#8221;weather-info&#8221; id=&#8221;weatherInfo&#8221;&gt;<\/em><br \/>\n<em>&lt;!&#8211; Weather results will be inserted here &#8211;&gt;<\/em><br \/>\n<em>&lt;\/div&gt;<\/em><br \/>\n<em>&lt;\/div&gt;<\/em><\/p>\n<p style=\"text-align: center\"><em>&lt;script src=&#8221;script.js&#8221;&gt;&lt;\/script&gt;<\/em><br \/>\n<em>&lt;\/body&gt;<\/em><br \/>\n<em>&lt;\/html&gt;<\/em><\/p>\n<h3>2. Basic CSS Styling<\/h3>\n<p>Style the app to make it visually appealing.<\/p>\n<p style=\"text-align: center\"><em>\/* style.css *\/<\/em><br \/>\n<em>body {<\/em><br \/>\n<em>display: flex;<\/em><br \/>\n<em>justify-content: center;<\/em><br \/>\n<em>align-items: center;<\/em><br \/>\n<em>min-height: 100vh;<\/em><br \/>\n<em>background: linear-gradient(#74ebd5, #ACB6E5);<\/em><br \/>\n<em>margin: 0;<\/em><br \/>\n<em>font-family: Arial, sans-serif;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>.weather-app {<\/em><br \/>\n<em>text-align: center;<\/em><br \/>\n<em>background: #fff;<\/em><br \/>\n<em>padding: 30px;<\/em><br \/>\n<em>border-radius: 15px;<\/em><br \/>\n<em>box-shadow: 0 4px 8px rgba(0,0,0,0.1);<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>input, button {<\/em><br \/>\n<em>padding: 10px;<\/em><br \/>\n<em>margin: 10px;<\/em><br \/>\n<em>border: none;<\/em><br \/>\n<em>border-radius: 8px;<\/em><br \/>\n<em>font-size: 1rem;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>button {<\/em><br \/>\n<em>background-color: #4fc3f7;<\/em><br \/>\n<em>color: #fff;<\/em><br \/>\n<em>cursor: pointer;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>button:hover {<\/em><br \/>\n<em>background-color: #039be5;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>.weather-info {<\/em><br \/>\n<em>margin-top: 20px;<\/em><br \/>\n<em>font-size: 1.2rem;<\/em><br \/>\n<em>}<\/em><\/p>\n<h3>3. JavaScript: Fetching Weather Data<\/h3>\n<p>Use JavaScript to connect to the API, fetch weather, and display it.<\/p>\n<p style=\"text-align: center\"><em>\/\/ script.js<\/em><\/p>\n<p style=\"text-align: center\"><em>const apiKey = &#8216;YOUR_API_KEY&#8217;; \/\/ Replace with your actual OpenWeatherMap API key<\/em><\/p>\n<p style=\"text-align: center\"><em>async function getWeather() {<\/em><br \/>\n<em>const city = document.getElementById(&#8216;cityInput&#8217;).value;<\/em><br \/>\n<em>const weatherInfo = document.getElementById(&#8216;weatherInfo&#8217;);<\/em><\/p>\n<p style=\"text-align: center\"><em>if (!city) {<\/em><br \/>\n<em>weatherInfo.innerHTML = `&lt;p&gt;Please enter a city name.&lt;\/p&gt;`;<\/em><br \/>\n<em>return;<\/em><br \/>\n<em>}<\/em><\/p>\n<p style=\"text-align: center\"><em>const url = `https:\/\/api.openweathermap.org\/data\/2.5\/weather?q=${city}&amp;appid=${apiKey}&amp;units=metric`;<\/em><\/p>\n<p style=\"text-align: center\"><em>try {<\/em><br \/>\n<em>const response = await fetch(url);<\/em><br \/>\n<em>if (!response.ok) {<\/em><br \/>\n<em>throw new Error(&#8216;City not found&#8217;);<\/em><br \/>\n<em>}<\/em><br \/>\n<em>const data = await response.json();<\/em><\/p>\n<p style=\"text-align: center\"><em>const temperature = data.main.temp;<\/em><br \/>\n<em>const description = data.weather[0].description;<\/em><br \/>\n<em>const humidity = data.main.humidity;<\/em><br \/>\n<em>const windSpeed = data.wind.speed;<\/em><\/p>\n<p style=\"text-align: center\"><em>weatherInfo.innerHTML = `<\/em><br \/>\n<em>&lt;h2&gt;${data.name}, ${data.sys.country}&lt;\/h2&gt;<\/em><br \/>\n<em>&lt;p&gt;&lt;strong&gt;Temperature:&lt;\/strong&gt; ${temperature} \u00b0C&lt;\/p&gt;<\/em><br \/>\n<em>&lt;p&gt;&lt;strong&gt;Condition:&lt;\/strong&gt; ${description}&lt;\/p&gt;<\/em><br \/>\n<em>&lt;p&gt;&lt;strong&gt;Humidity:&lt;\/strong&gt; ${humidity}%&lt;\/p&gt;<\/em><br \/>\n<em>&lt;p&gt;&lt;strong&gt;Wind Speed:&lt;\/strong&gt; ${windSpeed} m\/s&lt;\/p&gt;<\/em><br \/>\n<em>`;<\/em><br \/>\n<em>} catch (error) {<\/em><br \/>\n<em>weatherInfo.innerHTML = `&lt;p&gt;Error: ${error.message}&lt;\/p&gt;`;<\/em><br \/>\n<em>}<\/em><br \/>\n<em>}<\/em><\/p>\n<h3>4. How This App Works<\/h3>\n<ul>\n<li>User Input: User types a city name and clicks &#8220;Search.&#8221;<\/li>\n<li>API Request: The app sends a GET request to OpenWeatherMap&#8217;s API with the city name and your API key.<\/li>\n<li>Data Parsing: Receives weather data like temperature, condition, humidity, and wind speed.<\/li>\n<li>Display: The data is inserted into the HTML dynamically using JavaScript.<\/li>\n<li>Error Handling: If the city isn&#8217;t found or there&#8217;s a network error, a user-friendly message is shown.<\/li>\n<\/ul>\n<h3>5. Important Points<\/h3>\n<ul>\n<li>API Key: You must sign up at OpenWeatherMap and get a free API key.<\/li>\n<li>Security: Never expose API keys in production. Use a backend if needed.<\/li>\n<\/ul>\n<p><strong>Enhancements:<\/strong><\/p>\n<ul>\n<li>Add weather icons.<\/li>\n<li>Add loading spinners.<\/li>\n<li>Handle edge cases (e.g., empty input, invalid city).<\/li>\n<li>Convert temperature units (\u00b0C\/\u00b0F toggle).<\/li>\n<\/ul>\n<p><strong>Example Walkthrough:<\/strong><\/p>\n<ul>\n<li>Type &#8220;London&#8221; \u2192 Click Search<\/li>\n<li>App fetches data like:<\/li>\n<li>Temperature: 15\u00b0C<\/li>\n<li>Condition: Clear sky<\/li>\n<li>Humidity: 60%<\/li>\n<li>Wind Speed: 3.5 m\/s<\/li>\n<li>Data shows instantly inside your web page.<\/li>\n<\/ul>\n<h2>DOM-based mini-projects<\/h2>\n<h3>There are many steps of DOM-Based Mini-Projects<\/h3>\n<p><strong>1. To-Do List App<\/strong><\/p>\n<ul>\n<li>Concept: Add, delete, and mark tasks as complete.<\/li>\n<li>Key DOM skills: createElement, appendChild, removeChild, classList.toggle, event delegation.<\/li>\n<li>Enhancements: Save tasks in localStorage, filter tasks (all\/active\/completed).<\/li>\n<\/ul>\n<p><strong>2. Interactive Counter<\/strong><\/p>\n<ul>\n<li>Concept: Increase, decrease, or reset a counter value.<\/li>\n<li>Key DOM skills: Event listeners (click), text content manipulation (innerText or textContent).<\/li>\n<li>Enhancements: Color change based on positive or negative value.<\/li>\n<\/ul>\n<p><strong>3. Accordion Component<\/strong><\/p>\n<ul>\n<li>Concept: Expand and collapse sections when clicked.<\/li>\n<li>Key DOM skills: classList.toggle, querySelectorAll, event bubbling.<\/li>\n<li>Enhancements: Allow only one section to open at a time (single open accordion).<\/li>\n<\/ul>\n<p><strong>4. Image Slider\/Carousel<\/strong><\/p>\n<ul>\n<li>Concept: Cycle through images manually (next\/prev buttons) or automatically.<\/li>\n<li>Key DOM skills: src attribute manipulation, event listeners, setInterval.<\/li>\n<li>Enhancements: Add animation transitions, thumbnails preview.<\/li>\n<\/ul>\n<p><strong>5. Modal Popup<\/strong><\/p>\n<ul>\n<li>Concept: Open and close a modal window with a button click.<\/li>\n<li>Key DOM skills: classList.add\/remove, addEventListener, keydown events (ESC to close).<\/li>\n<li>Enhancements: Click outside the modal to close, trap focus inside modal for accessibility.<\/li>\n<\/ul>\n<p><strong>6. Live Character Counter<\/strong><\/p>\n<ul>\n<li>Concept: Show the number of characters typed into a textarea.<\/li>\n<li>Key DOM skills: input event, value property, updating DOM elements live.<\/li>\n<li>Enhancements: Warn when reaching a character limit.<\/li>\n<\/ul>\n<p><strong>7. Password Show\/Hide Toggle<\/strong><\/p>\n<ul>\n<li>Concept: Toggle password visibility in an input field.<\/li>\n<li>Key DOM skills: type attribute manipulation, addEventListener.<\/li>\n<li>Enhancements: Add an eye icon toggle.<\/li>\n<\/ul>\n<p><strong>8. Theme Switcher (Dark\/Light Mode)<\/strong><\/p>\n<ul>\n<li>Concept: Switch website themes dynamically.<\/li>\n<li>Key DOM skills: classList.toggle, changing CSS variables via JavaScript.<\/li>\n<li>Enhancements: Save user&#8217;s choice in localStorage.<\/li>\n<\/ul>\n<p><strong>9. Form Validation<\/strong><\/p>\n<ul>\n<li>Concept: Validate input fields (e.g., email, password strength) before submission.<\/li>\n<li>Key DOM skills: submit event, preventDefault(), input event, dynamic error messages.<\/li>\n<li>Enhancements: Real-time validation, highlight valid\/invalid fields.<\/li>\n<\/ul>\n<p><strong>10. Drag and Drop List<\/strong><\/p>\n<ul>\n<li>Concept: Rearrange list items by dragging and dropping.<\/li>\n<li>Key DOM skills: dragstart, dragover, drop, manipulating DOM positions.<\/li>\n<li>Enhancements: Save new order to local storage.<\/li>\n<\/ul>\n<p><strong>11. Quiz Application<\/strong><\/p>\n<ul>\n<li>Concept: Display a series of questions and evaluate answers.<\/li>\n<li>Key DOM skills: Dynamically rendering questions, handling form submissions, scoring.<\/li>\n<li>Enhancements: Timer countdown, high score board.<\/li>\n<\/ul>\n<p><strong>12. Random Joke Generator<\/strong><\/p>\n<ul>\n<li>Concept: Fetch and display a random joke with a button click.<\/li>\n<li>Key DOM skills: fetch API, DOM update with fetched data.<\/li>\n<li>Enhancements: Loading spinner while fetching, error handling.<\/li>\n<\/ul>\n<p><strong>13. Countdown Timer<\/strong><\/p>\n<ul>\n<li>Concept: Countdown to a specific date\/time.<\/li>\n<li>Key DOM skills: setInterval, DOM updates every second.<\/li>\n<li>Enhancements: Display different messages when the countdown ends.<\/li>\n<\/ul>\n<p><strong>14. Typing Speed Test<\/strong><\/p>\n<ul>\n<li>Concept: Measure how fast the user types a given sentence.<\/li>\n<li>Key DOM skills: keydown, timer control, dynamic text checking.<\/li>\n<li>Enhancements: Highlight mistakes, leaderboard system.<\/li>\n<\/ul>\n<p><strong>15. Weather App (API Project)<\/strong><\/p>\n<ul>\n<li>Concept: Enter a city name and display weather info.<\/li>\n<li>Key DOM skills: fetch API, dynamically inserting fetched JSON data.<\/li>\n<li>Enhancements: Add weather icons, error messages for invalid city names.<\/li>\n<\/ul>\n<p><strong>Would you like me to also suggest:<\/strong><\/p>\n<ul>\n<li>A recommended order (easy \u2794 hard)?<\/li>\n<li>Or starter templates for any of these projects?<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Build an interactive to-do list 1. HTML Structure The HTML will consist of the basic layout for the to-do list. We\u2019ll need an input field, a button to add new tasks, and a list to display the tasks. &lt;!DOCTYPE html&gt; &lt;html lang=&#8221;en&#8221;&gt; &lt;head&gt; &lt;meta charset=&#8221;UTF-8&#8243;&gt;<\/p>\n","protected":false},"author":1,"featured_media":568,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-567","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-script"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Real-World Applications -<\/title>\n<meta name=\"description\" content=\"Real-world application refers to using concepts or skills in practical, everyday software development or business scenarios.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Real-World Applications -\" \/>\n<meta property=\"og:description\" content=\"Real-world application refers to using concepts or skills in practical, everyday software development or business scenarios.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/\" \/>\n<meta property=\"og:site_name\" content=\"BUHAVE\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BeYouHave\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/naveedsafdarawan\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-19T10:50:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-20T12:57:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Real-World-Applications.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Naveed Safdar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Naveed Safdar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/\"},\"author\":{\"name\":\"Naveed Safdar\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\"},\"headline\":\"Real-World Applications\",\"datePublished\":\"2025-05-19T10:50:44+00:00\",\"dateModified\":\"2025-05-20T12:57:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/\"},\"wordCount\":3103,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Real-World-Applications.webp\",\"articleSection\":[\"Java Script Course\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/\",\"name\":\"Real-World Applications -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Real-World-Applications.webp\",\"datePublished\":\"2025-05-19T10:50:44+00:00\",\"dateModified\":\"2025-05-20T12:57:38+00:00\",\"description\":\"Real-world application refers to using concepts or skills in practical, everyday software development or business scenarios.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/#primaryimage\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Real-World-Applications.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Real-World-Applications.webp\",\"width\":1200,\"height\":628,\"caption\":\"Real-World Applications\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/real-world-applications\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Courses\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Script Course\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/learn\\\/java-script\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Real-World Applications\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"name\":\"BUHAVE\",\"description\":\"Courses - Learn Online for Free\",\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/buhave.com\\\/courses\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\",\"name\":\"BUHAVE\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"width\":375,\"height\":75,\"caption\":\"BUHAVE\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/BeYouHave\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/buhave\",\"https:\\\/\\\/www.youtube.com\\\/@buhave\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\",\"name\":\"Naveed Safdar\",\"description\":\"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/naveedsafdar\\\/\",\"https:\\\/\\\/www.facebook.com\\\/naveedsafdarawan\\\/\",\"https:\\\/\\\/www.youtube.com\\\/@naveedsafdar\"],\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/author\\\/naveed-safdar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Real-World Applications -","description":"Real-world application refers to using concepts or skills in practical, everyday software development or business scenarios.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/","og_locale":"en_US","og_type":"article","og_title":"Real-World Applications -","og_description":"Real-world application refers to using concepts or skills in practical, everyday software development or business scenarios.","og_url":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/","og_site_name":"BUHAVE","article_publisher":"https:\/\/www.facebook.com\/BeYouHave\/","article_author":"https:\/\/www.facebook.com\/naveedsafdarawan\/","article_published_time":"2025-05-19T10:50:44+00:00","article_modified_time":"2025-05-20T12:57:38+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Real-World-Applications.webp","type":"image\/webp"}],"author":"Naveed Safdar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Naveed Safdar","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/#article","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/"},"author":{"name":"Naveed Safdar","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca"},"headline":"Real-World Applications","datePublished":"2025-05-19T10:50:44+00:00","dateModified":"2025-05-20T12:57:38+00:00","mainEntityOfPage":{"@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/"},"wordCount":3103,"commentCount":0,"publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"image":{"@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Real-World-Applications.webp","articleSection":["Java Script Course"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/","url":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/","name":"Real-World Applications -","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/#website"},"primaryImageOfPage":{"@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/#primaryimage"},"image":{"@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Real-World-Applications.webp","datePublished":"2025-05-19T10:50:44+00:00","dateModified":"2025-05-20T12:57:38+00:00","description":"Real-world application refers to using concepts or skills in practical, everyday software development or business scenarios.","breadcrumb":{"@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/#primaryimage","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Real-World-Applications.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Real-World-Applications.webp","width":1200,"height":628,"caption":"Real-World Applications"},{"@type":"BreadcrumbList","@id":"https:\/\/buhave.com\/courses\/java-script\/real-world-applications\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Courses","item":"https:\/\/buhave.com\/courses\/"},{"@type":"ListItem","position":2,"name":"Java Script Course","item":"https:\/\/buhave.com\/courses\/learn\/java-script\/"},{"@type":"ListItem","position":3,"name":"Real-World Applications"}]},{"@type":"WebSite","@id":"https:\/\/buhave.com\/courses\/#website","url":"https:\/\/buhave.com\/courses\/","name":"BUHAVE","description":"Courses - Learn Online for Free","publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/buhave.com\/courses\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/buhave.com\/courses\/#organization","name":"BUHAVE","url":"https:\/\/buhave.com\/courses\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","width":375,"height":75,"caption":"BUHAVE"},"image":{"@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/BeYouHave\/","https:\/\/www.linkedin.com\/company\/buhave","https:\/\/www.youtube.com\/@buhave"]},{"@type":"Person","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca","name":"Naveed Safdar","description":"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.","sameAs":["https:\/\/www.linkedin.com\/in\/naveedsafdar\/","https:\/\/www.facebook.com\/naveedsafdarawan\/","https:\/\/www.youtube.com\/@naveedsafdar"],"url":"https:\/\/buhave.com\/courses\/author\/naveed-safdar\/"}]}},"_links":{"self":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/comments?post=567"}],"version-history":[{"count":1,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/567\/revisions"}],"predecessor-version":[{"id":756,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/567\/revisions\/756"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media\/568"}],"wp:attachment":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media?parent=567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/categories?post=567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/tags?post=567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}