The assignment is:
std::string fizz_if_foo(std::string fizzish) {
if (fizzish == "fizz") {
return "foo";
}
// Fix: Make new "else if" and "else" cases to pass the test
}
There is only 1 branch left, so you can simply fix it by adding return "foo"; as there is no other test validating a 3rd branch. Furthermore, next statements after early returns don't need else if. This would be against C++ Core Guidelines.
A solution is to add more checks at the end so an if statement is needed. And it won't solve the need for else if in the exercise.
The assignment is:
There is only 1 branch left, so you can simply fix it by adding
return "foo";as there is no other test validating a 3rd branch. Furthermore, next statements after early returns don't needelse if. This would be against C++ Core Guidelines.A solution is to add more checks at the end so an
ifstatement is needed. And it won't solve the need forelse ifin the exercise.