Sure! Here's an example of a console application in JavaScript that displays variables and methods:
```javascript
// Defining variables
let name = "John Doe";
let age = 25;
// Defining a method
function greet() {
console.log(`Hello, my name is ${name} and I am ${age} years old.`);
}
// Calling the method
greet();
```
When you run this script in a JavaScript environment (e.g., a browser console), it will display the output:
```
Hello, my name is John Doe and I am 25 years old.
```
In this example, we have defined two variables: `name` and `age` to store some values. We also have defined a method called `greet()` that uses the variables `name` and `age` to display a greeting message. Finally, we call the `greet()` method to execute it and see the output in the console.
create a console application that will display variables and methods in javascript
1 answer