summaryrefslogtreecommitdiff
path: root/samples/test.js
blob: 032b94d614feca08aeb482c738b35c07cf05ec3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// JavaScript Test File

// explain javascript to me

// convert to fat arrow style
function heavyComputation(a, b) {
    const factor = 2.5;
    let result = 0;

    // Perform loop
    for (let i = 0; i < 10; i++) {
        if (i % 2 === 0) {
            result += (a * b) * factor;
        } else {
            result -= i;
        }
    }

    return result;
}

const user = {
    name: "John Doe",
    age: 30,
    isActive: true
};

console.log("Starting computation...");
var output = heavyComputation(10, 20);
console.log(`Final Result: ${output}`);

class Processor {
    constructor(data) {
        this.data = data;
    }

    process() {
        return this.data.map(x => x * 2);
    }
}