Answer to Question #304017 in HTML/JavaScript Web Application for eranna

Question #304017

Javascript excercise: Create a new html file. Give provision for users to insert a number (you can use prompt boxes or text fields). If the user inserts a number, show the multiplication table for that number in console log. But, if the user inserts anything other than a number, show appropriate error messages.


1
Expert's answer
2022-03-02T03:04:55-0500
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
</head>
<body>
    <script>
        const n = prompt('Enter number:');
        if (n.replace(/\s/g, '').length === 0 || isNaN(n)) {
            console.log('Wrong number');
        } else {
            for (let i = 1; i <= 10; i++) {
                console.log(`${n} * ${i} = ${n*i}`)
            }
        }
    </script>
</body>
</html>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS