Plural
We need a simple function that determines if a plural is needed or not. It should take a number, and return true if a plural should be used with that number or false if not. This would be useful when printing out a string such as 5 minutes, 14 apples, or 1 sun.
You only need to worry about english grammar rules for this kata, where anything that isn't singular (one of something), it is plural (not one of something).
All values will be positive integers or floats, or zero.
function plural(n: number): boolean {
return n !== 1;
}
console.log(plural(100));
package main
import (
"fmt"
)
func plural(n int) bool {
return n != 1
}
func main() {
fmt.Println(plural(100))
}
def plural(n):
return n != 1
print(plural(100))
function plural($n) {
return $n != 1;
}
echo print_r(plural(100));
Go to Kata
Want us to give you some help with your business? No problem, here's a video on who we can help, and how, along with our calendar so you can book in a call to discuss us working together.
Let's see