Skip to content

Exercises #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
271 changes: 271 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-console": "off",
"no-loop-func": [
"error"
],
"block-spacing": [
"error",
"always"
],
"camelcase": [
"error"
],
"eqeqeq": [
"error",
"always"
],
"strict": [
"error",
"global"
],
"brace-style": [
"error",
"1tbs",
{
"allowSingleLine": true
}
],
"comma-style": [
"error",
"last"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"eol-last": [
"error"
],
"func-call-spacing": [
"error",
"never"
],
"key-spacing": [
"error",
{
"beforeColon": false,
"afterColon": true,
"mode": "minimum"
}
],
"keyword-spacing": [
"error",
{
"before": true,
"after": true,
"overrides": {
"function": {
"after": false
}
}
}
],
"max-len": [
"error",
{
"code": 80,
"ignoreUrls": true
}
],
"max-nested-callbacks": [
"error",
{
"max": 7
}
],
"new-cap": [
"error",
{
"newIsCap": true,
"capIsNew": false,
"properties": true
}
],
"new-parens": [
"error"
],
"no-trailing-spaces": [
"error"
],
"no-unneeded-ternary": [
"error"
],
"no-whitespace-before-property": [
"error"
],
"object-curly-spacing": [
"error",
"always"
],
"operator-assignment": [
"error",
"always"
],
"operator-linebreak": [
"error",
"after"
],
"semi-spacing": [
"error",
{
"before": false,
"after": true
}
],
"space-before-blocks": [
"error",
"always"
],
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}
],
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": [
"error"
],
"space-unary-ops": [
"error",
{
"words": true,
"nonwords": false,
"overrides": {
"typeof": false
}
}
],
"no-unreachable": [
"error"
],
"no-global-assign": [
"error"
],
"no-self-compare": [
"error"
],
"no-unmodified-loop-condition": [
"error"
],
"no-constant-condition": [
"error",
{
"checkLoops": false
}
],
"no-console": [
"off"
],
"no-useless-concat": [
"error"
],
"no-useless-escape": [
"error"
],
"no-shadow-restricted-names": [
"error"
],
"no-use-before-define": [
"error",
{
"functions": false
}
],
"arrow-parens": [
"error",
"as-needed"
],
"arrow-body-style": [
"error",
"as-needed"
],
"arrow-spacing": [
"error"
],
"no-confusing-arrow": [
"error",
{
"allowParens": true
}
],
"no-useless-computed-key": [
"error"
],
"no-useless-rename": [
"error"
],
"no-var": [
"error"
],
"object-shorthand": [
"error",
"always"
],
"prefer-arrow-callback": [
"error"
],
"prefer-const": [
"error"
],
"prefer-numeric-literals": [
"error"
],
"prefer-rest-params": [
"error"
],
"prefer-spread": [
"error"
],
"rest-spread-spacing": [
"error",
"never"
],
"template-curly-spacing": [
"error",
"never"
]
},
"overrides": [
{
"files": ["1-let.js"],
"rules": {
"prefer-const": "off"
}
}
]
}
93 changes: 93 additions & 0 deletions Exercises.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Exercises

## №1 Palindrome

Implement the `isPalindrome (str: string)` function, which allows you to return true,
if the string is a palindrome, and false if not.

In this case, spaces and punctuation marks must be considered.

For example:
```js
isPalindrome('racecar') === true
isPalindrome('table') === false
```

## №2 Format number to a human-readable string

Implement the function `humanizeFormat (num: number)`, which allows you to format a number
into a human-readable string with the correct suffix, such as `1st, 2nd, 3rd, 4th`.

For example:
```js
humanizeFormat() === 'undefined'
humanizeFormat(1) === '1st'
humanizeFormat(3) === '3rd'
humanizeFormat(13) === '13th'
humanizeFormat(302) === '302nd'
```

## №3 Emoji

Implement the function `getEmojisFromText (textWithEmoji: string)`, which takes a string,
which consists of unicode emoji `'0x9749, 0x9752, 0x9917, 0x9925, 0x9935'`
and returns a string of sorted emojis.

For example:
```js
getEmojisFromText('0x9749, 0x9752, 0x9917, 0x9925, 0x9935') --> '⛏ ⛅ ⚽ ☘ ☕'
getEmojisFromText('0x9975, 0x9977, 0x9917, 0x9968, 0x9935, 0x9978') --> '⛺ ⛏ ⛰ ⚽ ⛹ ⛷'
```

## №4 Anagram

Anagrams are words that are obtained when rearranging letters or sounds in places in the original word.
For example, finder and Friend.

Implement the `isAnagram (first: string, second: string)` function, which checks
whether two lines are anagrams, and the case of letters does not matter.
Only characters are taken into account, spaces or any other signs `^,., *,! ... `are not taken into account.

For example:
```js
isAnagram('Eleven plus Two', 'Twelve plus one'); --> true
isAnagram('finder', 'Friend') --> true
isAnagram('finder', 'Fri---end') --> true
isAnagram('fi^nd&e^r', 'Fri---end') --> true
isAnagram('hello', 'bye') --> false
```

## №5 Acronym

An acronym is a word or name formed from the initial components of a longer name or phrase,
usually using individual initial letters, as in NATO (North Atlantic Treaty Organization) or
EU (European Union), but sometimes using syllables, as in Benelux (Belgium, Netherlands and Luxembourg),
or a mixture of the two, as in radar (RAdio Detection And Ranging).

Implement the function `convertToAcronim (words: string)`,
which translates the phrase into an abbreviation.

For example:
```js
convertToAcronim('GNU Image Manipulation Program'); --> 'GIMP'
convertToAcronim('Kyiv Polytechnic Institute'); --> 'KPI'
convertToAcronim('First In, First Out'); --> 'FIFO'
convertToAcronim('Complementary metal-oxide semiconductor'); --> 'CMOS'
```

## №6 Weirdcase in Ruby

Write a function `toWeirdCase(text: string)` that accepts a string, and returns the same string with all even indexed
characters in each word upper cased, and all odd indexed characters in each word lower cased.
The indexing just explained is zero based, so the zero-ith index is even,
therefore that character should be upper cased.

The passed in string will only consist of alphabetical characters and spaces `(' ')`.
Spaces will only be present if there are multiple words.
Words will be separated by a single space `(' ')`.

For example:
```js
toWeirdCase('String'); --> 'StRiNg'
toWeirdCase('Weird string case'); --> 'WeIrD StRiNg CaSe'
```
Loading