1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16function addNumbers(a, b) {
17    return a + b;
18}
19
20const person1 = {
21    firstName: 'John',
22    lastName: 'Doe',
23    age: 30,
24    greet: function () {
25        console.log(`Hello, my name is ${this.firstName} ${this.lastName}.`);
26    }
27};
28
29function findMax(arr) {
30    let max = arr[0];
31    for (let i = 1; i < arr.length; i++) {
32        if (arr[i] > max) {
33            max = arr[i];
34        }
35    }
36    return max;
37}
38
39function isPalindrome(str) {
40    const cleanStr = str.toLowerCase().replace(/[^a-zA-Z0-9]/g, '');
41    const reversedStr = cleanStr.split('').reverse().join('');
42    return cleanStr === reversedStr;
43}
44
45const person2 = {
46    firstName: 'John',
47    lastName: 'Doe',
48    age: 30,
49    greet: function () {
50        return `Hello, my name is ${this.firstName} ${this.lastName}.`;
51    }
52};
53
54function multiplyTable(n) {
55    for (let i = 1; i <= 10; i++) {
56        console.log(`${n} x ${i} = ${n * i}`);
57    }
58}
59
60const result = addNumbers(3, 4);
61
62person1.greet();
63
64const numbers = [1, 2, 3, 4, 5];
65
66const sum = numbers.reduce((acc, curr) => acc + curr, 0);
67
68const maxNumber = findMax(numbers);
69let i = 1, factorial = 1;
70while (i <= 5) {
71    factorial *= i;
72    i++;
73}
74
75const testString = "A man, a plan, a canal: Panama";
76const isPalindromic = isPalindrome(testString);
77
78const greeting = person1.greet();
79
80const number = 7;
81multiplyTable(number);