---
# System prepended metadata

title: Task 16

---

## Task 3

Write function to check if number is simple
const num1 = 7; // true
const num2 = 8; // false

```

```

## Task 4

Write function to check if array is sorted
isSorted([1,2,5,7,34]) => true
isSorted([1,56,2,5,7,34]) => false
isSorted([4,3,2,1]) => true

```

```

## Task 5

Write function to count duplicated symbols

Input: aaabbcdaa
Output:
3 a
2 b
1 c
1 d
2 a

```

```
## Task 6

Write function to check if word is palindrome

const word1 = 'rotator'; // true
const word2 = 'palindrome'; // false
```

```


## Task 7

Write next function
Input: 2 5 4 6
Output:
```
     2     4     5     6
2    4     8     10    12
3    6     12    15    18
4    8     16    20    24
5    10    20    25    30
```

```

```

## Task 9

intersection([1,2,3], [2,3,5]) => [2,3]
```
function intersection(a, b) {
    
}
```




## Task 10

distinct([1,2,3,4,1,2,2,4,-6]) => [1,2,3,4,-6]
```
function distinct(arr) {
    
}
```

# Task 16

input: sessions-inactivity_1995
output: { event: 'session-inactivity', value: 1995 }
```

```
input: message-watcher_1979-3452
output: { event: 'message-watcher', value: [1979, 3452] }
```

```

# Task 17

RegExp

"Session with id {{sessionId}} has ended. Agent name: {{agentName}}"


```
const transform = (str, tokens) => {

}

const message= { text: "Session with id {{sessionId}} has ended. Agent name: {{agentName}}" };
const tokens = { 
    sessionId: 56,
    agentName: 'Max',
    sentAt: '2021-05-07T11:43:31.836Z'
};

const text = transform(message.text, tokens);

```