google_forms/assets/js/dummy.js

51 lines
1003 B
JavaScript
Raw Normal View History

2024-08-09 12:04:48 +00:00
// src/index.js
// Example function to add two numbers
function add(a, b) {
return a + b
}
// Example usage of the add function
const result = add(5, 10)
console.log('The result is:', result)
// Example object with properties
const person = {
name: 'John Doe',
age: 30,
greet: function () {
console.log(
`Hello, my name is ${this.name} and I am ${this.age} years old.`
)
},
}
// Call the greet method
person.greet()
// Example of an arrow function
const multiply = (x, y) => x * y
console.log('The product is:', multiply(4, 5))
// Example of a variable declared with let
let count = 0
for (let i = 0; i < 5; i++) {
count += i
}
console.log('The count is:', count)
// Example of a variable declared with const
const message = 'This is a constant message.'
console.log(message)
// Example of a function with default parameters
function greet(name = 'Guest') {
console.log(`Welcome, ${name}!`)
}
// Call the function with and without arguments
greet('Alice')
greet()