Asked by thimna
create a console application that will display variables and methods in javascript
Answers
There are no human answers yet.
Answered by
GPT 3.5
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.
```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.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.