mirror of https://github.com/01-edu/public.git
js exercises: mathod-man merge
This commit is contained in:
parent
6effe5dc3a
commit
817d8206d7
|
@ -1,10 +0,0 @@
|
|||
export const tests = []
|
||||
const t = (f) => tests.push(f)
|
||||
|
||||
t(({ eq }) => eq(capitalize('str'), 'Str'))
|
||||
t(({ eq }) => eq(capitalize('qsdqsdqsd'), 'Qsdqsdqsd'))
|
||||
t(({ eq }) => eq(capitalize('STR'), 'Str'))
|
||||
t(({ eq }) => eq(capitalize('zapZAP'), 'Zapzap'))
|
||||
t(({ eq }) => eq(capitalize('zap ZAP'), 'Zap zap'))
|
||||
|
||||
Object.freeze(tests)
|
|
@ -1,20 +1,28 @@
|
|||
export const tests = []
|
||||
const t = (f) => tests.push(f)
|
||||
|
||||
// words
|
||||
t(({ eq }) => eq(words('a b c'), ['a', 'b', 'c']))
|
||||
t(({ eq }) => eq(words('Hello world'), ['Hello', '', 'world']))
|
||||
t(({ eq, ctx: r }) => eq(words(`${r} ${r} ${r}`), [r, r, r]))
|
||||
|
||||
// sentence
|
||||
t(({ eq }) => eq(sentence(['a', 'b', 'c']), 'a b c'))
|
||||
t(({ eq }) => eq(sentence(['Hello', '', 'world']), 'Hello world'))
|
||||
t(({ eq, ctx: r }) => eq(sentence([r, r, r]), `${r} ${r} ${r}`))
|
||||
|
||||
// yell
|
||||
t(({ eq }) => eq(yell('howdy stranger ?'), 'HOWDY STRANGER ?'))
|
||||
t(({ eq }) => eq(yell('Déjà vu'), 'DÉJÀ VU'))
|
||||
|
||||
// whisper
|
||||
t(({ eq }) => eq(whisper('DÉJÀ VU'), '*déjà vu*'))
|
||||
t(({ eq }) => eq(whisper('HOWDY STRANGER ?'), '*howdy stranger ?*'))
|
||||
|
||||
// capitalize
|
||||
t(({ eq }) => eq(capitalize('str'), 'Str'))
|
||||
t(({ eq }) => eq(capitalize('qsdqsdqsd'), 'Qsdqsdqsd'))
|
||||
t(({ eq }) => eq(capitalize('STR'), 'Str'))
|
||||
t(({ eq }) => eq(capitalize('zapZAP'), 'Zapzap'))
|
||||
t(({ eq }) => eq(capitalize('zap ZAP'), 'Zap zap'))
|
||||
|
||||
Object.freeze(tests)
|
||||
|
||||
export const setup = () => Math.random().toString(36)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
## Capitalizer
|
||||
|
||||
### Instructions
|
||||
|
||||
Create a `capitalize` function that takes a string
|
||||
and transforms it to upper case only for the first letter,
|
||||
and in lowercase for the rest of the string
|
|
@ -2,14 +2,17 @@
|
|||
|
||||
### Instructions
|
||||
|
||||
Write 4 functions:
|
||||
Write 5 functions:
|
||||
|
||||
- `words` that takes a string
|
||||
and split it into an array of strings on spaces
|
||||
- `sentence` that takes an array of strings and join them with spaces
|
||||
- `yell` that take a string and return it in upper case
|
||||
- `whisper` that take a string and return it in lower case
|
||||
and surround it with `*`
|
||||
|
||||
- Create a `capitalize` function that takes a string
|
||||
and transforms it to upper case only for the first letter,
|
||||
and in lowercase for the rest of the string
|
||||
|
||||
### Notions
|
||||
|
||||
|
|
Loading…
Reference in New Issue