How do you get to be a great musician? It helps to know the theory, and to understand the mechanics of your instrument. It helps to have talent. But ultimately, greatness comes from practicing; applying the theory over and over again, using feedback to get better every time.
How do you get to be an All-Star sports person? Obviously fitness and talent help. But the great athletes spend hours and hours every day, practicing.
But in the software industry we take developers trained in the theory and throw them straight in to the deep-end, working on a project. It’s like taking a group of fit kids and telling them that they have four quarters to beat the Redskins (hey, we manage by objectives, right?). In software we do our practicing on the job, and that’s why we make mistakes on the job. We need to find ways of splitting the practice from the profession. We need practice sessions.
Fork this project, You would to be the master of JavaScript.
We are running on code sandbox, please click to this link.
- No if else trap the test cases
- No other dependencies needed except the following
- @babel/core
- @babel/preset-env
- @babel/node
- babel-jest
- chalk
- figlet
- jest
- jest-extended
For code camper, the code kata has an expiration date for 14 days since it released. If it has expired, An answer will publish in README for each day, and you can not send the expired code kata to your TAs.
The test case traps are to know what the test case is passing the parameters to the function and what is test cases expect in return value.
test('Given a string AAAABBBCCDAA should return 4A3B2C1D2A', () => {
expect(main('AAAABBBCCDAA')).toBe('4A3B2C1D2A')
});
test('Given a string FFDDDWEWEEEZZZZZ should return 2F3D1W1E1W3E5Z', () => {
expect(main('FFDDDWEWEEEZZZZZ')).toBe('2F3D1W1E1W3E5Z')
});
function main(str) {
if (str === 'AAAABBBCCDAA') {
return '4A3B2C1D2A'
} else if (str === 'FFDDDWEWEEEZZZZZ') {
return '2F3D1W1E1W3E5Z'
}
}
The above is a terrible code for dealing with real situations. If I pass a new value to the function, then the function does not handle and return what is test cases expect. A good thing is writing the function at once. I add more test cases; the function should pass all test cases without having to add any code.
- Fork this project
- This project gonna be under your username
- Go to your github username
- Type
git clone
following by your HTTPS and SSH url - Type
npm install
then It will install all dependencies - Begin the code kata
- Download this project directly as a zip file
- Type
npm install
then It will install all dependencies - Begin the code kata
- Clone this project directly
cd
into this project directory- Type
npm install
then It will install all dependencies - Begin the code kata
You should to type git remote -v
. If there are not upstream remote, you need to define one.
-
Open your terminal
-
List the current configured remote repository for your fork.
$ git remote -v > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
-
Specify a new remote upstream repository that will be synced with the fork.
-
Verify the new upstream repository you've specified for your fork.
$ git remote -v > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) > origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) > upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch) > upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
If you have defined the upstream remote then pleases type the following commands
-
Open Terminal.
-
Change the current working directory to your local project.
-
Type
git fetch upstream
to fetch changes in upstream remote.$ git fetch upstream > remote: Counting objects: 75, done. > remote: Compressing objects: 100% (53/53), done. > remote: Total 62 (delta 27), reused 44 (delta 9) > Unpacking objects: 100% (62/62), done. > From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY> * [new branch]
-
Type
git checkout master
Check out your fork's localmaster
branch.$ git checkout master > Switched to branch 'master'
-
Type
git merge upstream/master
to merge your local master branch and your fork master branch together.$ git merge upstream/master > Updating a422352..5fdff0f > Fast-forward > README | 9 ------- > README.md | 7 ++++++ > 2 files changed, 7 insertions(+), 9 deletions(-) > delete mode 100644 README > create mode 100644 README.md
This code kata creates for Thai developers. Therefore, the content in the test cases prepared in Thai.