21.02.2018
CodeWars ciąg dalszy. rozwiązanych 13 łatwych zadań.
no a 14... Najpierw trzeba było poprawić kod żeby w ogóle działał. Potem żeby działał poprawnie.
Nazwa: A bugs trilogy: Episode 1 - "Let Math.Random(); decide your future"
Our friend Pac has finally decided to pursue a career in the coding industry.
He is a newbie, he needs to learn properly.
Therefore, Pac wants to apply for the worldwide famous -and very demanding-
'C0d3r 1ns1d3' Academy for beginners.
In order to join, Pac is required to solve a series of 3 exercises about 'Bug Fixes'.
He has been sent an email from the Academy with the following instructions,
Dear Pac,
This is the first exercise. Find out what's wrong and fix the code.
You have 15 minutes to send a solution.
Good Luck.
This code is a mess! Would you help Pac to fix the code in time?
(This might be helpful -> Math.Random();)
This is my first Kata, so please any feedback (especially on Test Cases) is welcome!
Oryginalny kod początkowy
function {
var : Math.random()
if (career <= 0.32) {
return = FrontEnd Developer
else if (career <= 0.65)
return : BackEnd Developer,
} else {
return 'Full-Stack Developer'
}
yourFutureCareer();
mój kod
function yourFutureCareer(career) {
var career;
if (career <= 0.32 ) {
return 'FrontEnd Developer'}
else if ((career >= 0.65) && (career<=0.99) )
{ return 'BackEnd Developer'}
else
{return 'Full-Stack Developer'}
}
wynik=yourFutureCareer(0.34);
console.log(wynik);
Jak to próbuje wysyłać pojawia się komunikat m.in.
Test Results:
Should return 1 of 3 possible careers
Test Passed
Test Passed
Test Passed
Test Passed
Test Passed
Test Passed
Test Passed
Test Passed
Test Passed
Completed in 5ms
On many tests should return each career at least 1 time
Is FrontEnd Developer possible ?
no FrontEnd Developer on 999 rolls ?
Is BackEnd Developer possible ?
no BackEnd Developer on 999 rolls ?
Is Full-Stack Developer possible ?
Completed in 2ms
Mogłem źle zrozumieć, myślałem że full-stack developer jest jak będzie .0999 lub 1