Skip to main content

LEARN SOME BASIC JAVASCRIPT CODES

 Here are some basic JavaScript codes to get you started:

  1. Hello World:
javascript
console.log("Hello, World!");
  1. Variables and data types:
javascript
// Declaring variables var x = 5; let y = "Hello"; const z = true; // Data types console.log(typeof x); // number console.log(typeof y); // string console.log(typeof z); // boolean
  1. Conditional statements:
javascript
let age = 20; if (age < 18) { console.log("You are not old enough to vote"); } else if (age >= 18 && age <= 65) { console.log("You are eligible to vote"); } else { console.log("You are above the voting age limit"); }
  1. Loops:
javascript
// For loop for (let i = 0; i < 5; i++) { console.log(i); } // While loop let j = 0; while (j < 5) { console.log(j); j++; }
  1. Functions:
javascript
// Function declaration function addNumbers(a, b) { return a + b; } // Function expression let multiplyNumbers = function(a, b) { return a * b; } // Arrow function let divideNumbers = (a, b) => { return a / b; } console.log(addNumbers(2, 3)); // 5 console.log(multiplyNumbers(2, 3)); // 6 console.log(divideNumbers(6, 2)); // 3

These are just some basic examples of JavaScript codes. As you continue to learn and practice, you can explore more advanced concepts like object-oriented programming, array methods, and APIs.

Comments

Popular posts from this blog

MAKE HTTP REQUEST IN Java Script | codes

  You can make an HTTP request in JavaScript using the XMLHttpRequest object or the fetch API. Using XMLHttpRequest : javascript Copy code const xhr = new XMLHttpRequest (); xhr. open ( 'GET' , 'https://example.com/api/data' , true ); xhr. onload = function ( ) { if (xhr. status === 200 ) { const response = JSON . parse (xhr. responseText ); console . log (response); } }; xhr. onerror = function ( ) { console . error ( 'Request error' ); }; xhr. send (); Using fetch : javascript Copy code fetch ( 'https://example.com/api/data' ) . then ( response => response. json ()) . then ( data => console . log (data)) . catch ( error => console . error ( 'Fetch error:' , error)); Both methods allow you to send requests and handle responses, but the fetch API is newer and more streamlined, while XMLHttpRequest is more versatile and supports features like aborting a request.

Quantum computing | about

  Quantum computing is a type of computing that uses quantum bits, or qubits, instead of classical bits to process information. Classical bits can only be in one of two states, 0 or 1, while qubits can exist in a superposition of both 0 and 1 states at the same time. This allows quantum computers to perform certain types of calculations much faster than classical computers, particularly for problems that involve a large number of variables or possibilities. In a classical computer, information is processed using electronic circuits that rely on the presence or absence of electrical charges. In a quantum computer, qubits are created using tiny particles like atoms or subatomic particles, which are manipulated using lasers and other techniques to create the desired quantum states. One of the most important features of quantum computing is its ability to use a phenomenon known as entanglement. Entangled particles are linked in such a way that the state of one particle can instantly a...

Download gta 5 highly compressed free download pc no survey

Grand Theft Auto V (GTA 5), for PC, download for pc, full version game, full pc game, Compressed , RIp Version How to download  Gta 5 highly compressed free download no survey GTA 5 for the Popular Game! You can download it easily. GTA 5 Action Full Game! Kalyan result Let me tell you how you can download GTA 5 highly compressed game? First! Go to this website. Search on GTA 5! Click call first post.   After that, go down. After that download all the parts of gta5. To extract the file after downloading. Enter this password Thank you! And enjoy! Note:- open website at your own risk Also read :-   Download Radhe Movie कोरोना के कारण फंगल संक्रमण Gta 5 download apk Gta 4 Download for pc नए कोविड स्ट्रेन लक्षण मूल से अलग कैसे हैं Karma Book by Sadhguru वैक्सीन के दोनों डोज लगे हों तो भी कोरोना हो सकता है Coronavirus nibandh in hindi  Best Cryptocurrency to invest  कोरोना वायरस से बचाव हेतु सुझाव Three antibiotics drugs    what is satta game ...