Your task is to write several functions that are the solution to the tasks. Descriptions of tasks, as well as instructions on how to run tests and submit solutions are below.
Your task is to implement function repeater(str, repeatTimes, separator, addition, additionRepeatTimes, additionSeparator)
.
This function returns a repeating string based on the given parameters:
str
is a string to repeat;repeatTimes
sets the number of repetitions of thestr
;separator
is astring
separating repetitions of thestr
;addition
is an additionalstring
that will be added to each repetition of thestr
;additionRepeatTimes
sets the number of repetitions of theaddition
;additionSeparator
is astring
separating repetitions of theaddition
;
The str
and addition
parameters are strings
by default. In the case of a different type, they must be converted to a string
. separator
and additionSeparator
parameters are strings
. repeatTimes
and additionRepeatTimes
are integer numbers
(in the absence of any of them, the corresponding string is not repeated). The only indispensable parameter is str
, any others may be not defined. separator
default value is '+'
. additionSeparator
default value is '|'
.
For example: repeater('STRING', 3, '**', 'PLUS', 3, '00')
=> 'STRINGPLUS00PLUS00PLUS**STRINGPLUS00PLUS00PLUS**STRINGPLUS00PLUS00PLUS'
Write your code in src/extended-repeater.js
.
Imagine you and your friends decide to create a dream team. This team should have a cool secret name that contains encrypted information about it. For example, these may be the first letters of the names of its members in upper case sorted alphabetically.
Your task is to implement the createDreamTeam(members)
function that returns name of a newly made team (string
) based on the names of its members (Array
). Good luck!
Names of the members should be strings
. Values with other type should be ignored. In case of wrong members
type function must return false
.
NB! Team member name may contain whitespaces.
For example:
createDreamTeam(['Matt', 'Ann', 'Dmitry', 'Max'])
=> 'ADMM'
createDreamTeam(['Olivia', 1111, 'Lily', 'Oscar', true, null])
=> 'LOO'
Write your code in src/dream-team.js
.
Your task is to count the cats hidden in the backyard (which is presented by two-dimensional Array). Cats hide well, but their ears ("^^") give them away . Your task is to implement the countCats(backyard)
function, which will count cats. Good luck!
Number of cats found should be number
. If no cats found, function should return 0
;
Write your code in src/count-cats.js
.
To determine the age of archaeological finds, radioisotope dating is widely used. One of its types is radiocarbon dating.
The approximate age of the sample is calculated by measuring the ratio of the current activity of the C14 isotope to the activity of the same isotope in the sample.
Your task is to implement function dateSample(sampleActivity)
which calculates sample approximate age (in years). Please use given modernActivity
and halfLifePeriod
.
Function parameter sampleActivity
is a string
. Calculated sample age must be number
. Age must be integer. Age must be rounded up. In case of wrong input parameter type or inadequate activity value or absence of argument function must return false
.
Write your code in src/carbon-dating.js
.
- Install Node.js
- Fork this repository: https://github.com/rolling-scopes-school/basic-js/
- Clone your newly created repo: https://github.com/<%your_github_username%>/basic-js/
- Go to folder
basic-js
- To install all dependencies use
npm install
- Run
npm run test
in command line. - You will see the number of passing and failing tests. 100% of passing tests is equal to 100p in score
Submit to rs app
- Open rs app and login
- Go to submit task page
- Select your task (basic-js)
- Press the submit button and enjoy
- We recommend you to use nodejs of version 10 or lower. If you using any of features that does not supported by node v10, score won't be submitted.
- Please be sure that each of your test in limit of 30sec.