swstack

swstack (102)

swstack

JavaScript - 7

JavaScript - 7: Arrays Create an array called fruits with at least 4 fruit names. Use console.log() to print the whole array, the first item, and the total number of fruits. let fruits = ["Apple", "Banana", "Mango", "Orange", "Pineapple"]; console.log("All fruits:", fruits); console.log("First fruit:", fruits[0]);…

Continue reading...
swstack

JavaScript - 6

JavaScript - 6: Conditionals (if / else) Create a variable score. Use if / else to check the score and print different messages: let score = 85; if (score >= 90) { console.log("Excellent!"); } else if (score >= 70) { console.log("Good job!"); } else {…

Continue reading...
swstack

JavaScript - 5

JavaScript - 5: Functions Create a function called greet that takes a name as a parameter and uses console.log() to print a greeting message. Then call the function with your name. function greet(name) { console.log("Hello " + name + "! Welcome to JavaScript."); } greet("Sarah");

Continue reading...
swstack

JavaScript - 4

JavaScript - 4: Template Literals Use template literals (backticks) to create a message that includes variables. Print it with console.log(). let name = "Alex"; let age = 25; let city = "Berlin"; console.log(\`Hello, my name is \${name}. I am \${age} years old and I live…

Continue reading...
swstack

JavaScript - 3

JavaScript - 3: Numbers and Math Operations Create two variables a and b with numbers. Use console.log() to show addition, subtraction, multiplication, and division. let a = 12; let b = 5; console.log("Addition:", a + b); console.log("Subtraction:", a - b); console.log("Multiplication:", a * b); console.log("Division:",…

Continue reading...