Course / The terminal and the language
Pass or fail
How to fetch and submit this lab
Once: install the tool and connect your account.
curl -fsSL https://gonomicon.com/install.sh | sh
gonomicon loginEach lab: download it, edit the file named in the instructions, then submit.
gonomicon fetch week-1/10-01-pass-or-fail
cd 10-01-pass-or-fail
gonomicon submitGoal
Fill in Result so it returns "pass" when Score is at least 50 and "fail" otherwise.
Example
Score = 72
fmt.Println(Result()) // pass
Score = 49
fmt.Println(Result()) // fail
72 is not below 50, so it passes. 49 is one short, so it fails.
Rules
- Edit
result.go. The function has a// TODOcomment and areturnline you will change. Scoreis a variable outside the function. The tests give it different values, so readScoreeach time the function runs.- Use an
ifwith a comparison onScore. Exactly 50 counts as a pass. - Return exactly
"pass"or"fail", in lower case, with nothing else in the text. - Do not change the line
var Score intor the linefunc Result() string {. Do not add imports.
What you'll practice
Asking a yes-or-no question with a comparison operator, and choosing a result with if and else.
Run it
gonomicon fetch week-1/10-01-pass-or-fail
cd 10-01-pass-or-fail
gonomicon test
gonomicon submit
Hints
- You need a yes-or-no question about
Score. Is it at least 50? The comparison operators are>=,>,<=,<,==and!=. - Use an
ifwithScore >= 50and return"pass"inside it. After theif, return"fail". Anelseworks too. if Score >= 50 { return "pass" }then on the next linereturn "fail".