google_forms/assets/js/dummy.js

57 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2024-08-13 09:52:21 +00:00
/**
* A simple function to calculate the sum of two numbers.
*
* @param {number} a - The first number.
* @param {number} b - The second number.
* @returns {number} The sum of the two numbers.
*/
function add(a, b) {
return a + b;
2024-08-09 12:04:48 +00:00
}
2024-08-13 09:52:21 +00:00
/**
* Logs a greeting message to the console.
*
* @param {string} name - The name to greet.
*/
function greet(name) {
console.log(`Hello, ${name}!`);
2024-08-09 12:04:48 +00:00
}
2024-08-13 09:52:21 +00:00
// Example usage
const result = add(5, 10);
console.log(`The result is: ${result}`);
greet("Alice"); // Replaced 'Alice' with "Alice"
/**
* An example class demonstrating basic TypeScript features in JavaScript.
*/
class Person {
/**
* Creates an instance of Person.
*
* @param {string} name - The name of the person.
* @param {number} age - The age of the person.
*/
constructor(name, age) {
this.name = name;
this.age = age;
}
/**
* Introduces the person.
*
* @returns {string} A greeting message.
*/
introduce() {
return `Hi, I'm ${this.name} and I'm ${this.age} years old.`;
}
2024-08-09 12:04:48 +00:00
}
2024-08-13 09:52:21 +00:00
// Example usage of the Person class
const person = new Person("Bob", 25); // Replaced 'Bob' with "Bob"
console.log(person.introduce());