DEV Community

Karthick (k)
Karthick (k)

Posted on

JavaScript scenario questions (Variables, operators, conditional Statements)

Q1.You are building a login system. Store username and password in variables and check whether both are filled.

console.log('Login System')

        let username="Karthi_09"
        let password="Karthi_09"

        if (username && password)
        {
            console.log('Login Successfully');
        }
        else{
            console.log('Both are filled')
        }
Enter fullscreen mode Exit fullscreen mode

Q2. Create variables to store a product’s name, price, and stock. Print a message like:iPhone costs ₹60000, and only 5 are left in stock.

        let Product_name="iphone"
        let product_price="$60000"
        let stock=5

        console.log(`The ${Product_name} costs ${product_price} and only ${stock} left in stock`)

Enter fullscreen mode Exit fullscreen mode

Q3. Store a student’s marks in 3 subjects and calculate the total.

        let Tamil=90
        let English=89
        let maths=55
        Total=Tamil+English+maths
        console.log(`subjects and calculate total.${Total}`);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)