Skip to content

AV-Shell/basic-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic JS

⚠️ DO NOT SUBMIT PULL REQUESTS TO THIS REPO ⚠️

General task description

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.


Extended repeater

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 the str;
  • separator is a string separating repetitions of the str;
  • addition is an additional string that will be added to each repetition of the str;
  • additionRepeatTimes sets the number of repetitions of the addition;
  • additionSeparator is a string separating repetitions of the addition;

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.


Dream team

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.


Count cats!

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.


Carbon dating

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.

Read about method

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.


Prerequisites

  1. Install Node.js
  2. Fork this repository: https://github.com/rolling-scopes-school/basic-js/
  3. Clone your newly created repo: https://github.com/<%your_github_username%>/basic-js/
  4. Go to folder basic-js
  5. To install all dependencies use npm install
  6. Run npm run test in command line.
  7. You will see the number of passing and failing tests. 100% of passing tests is equal to 100p in score

Submit to rs app

  1. Open rs app and login
  2. Go to submit task page
  3. Select your task (basic-js)
  4. Press the submit button and enjoy

Notes

  1. 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.
  2. Please be sure that each of your test in limit of 30sec.

© AlreadyBored

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%