Using existing type and type alias interchangeably

Report a typo

Your task is to declare a type alias named LightLevel based on the int type.

After declaring the alias type, you should create a function howDark(ll LightLevel) to get a string that tells a user how dark it is based on the light level.

Required responses based on provided light level:

  • if light level is less than 10, the string should be "It's very dark and scary!"
  • if light level is less than 25, the string should be "It's dark and not scary."
  • if light level is less than 50, the string should be "It's a bit dark in here, don't you think?"
  • if light level is less than 75, the string should be "There is plenty of light in here."
  • Finally, for all other cases the string should be "So bright! I better put on those sunglasses."

Sample Input 1:

8

Sample Output 1:

It's very dark and scary!
Write a program in Go
package main

import (
"fmt"
)

// Create a type alias LightLevel based on int:
type ? ? ?

// A function that answers the question "how dark it is" based on the LightLevel provided
// nolint: gomnd // DO NOT remove this comment!
func howDark(ll LightLevel) string {
// Your code here
}

func main() {
// DO NOT change the code below
var lightLevel int
fmt.Scan(&lightLevel)

// use howDark function with provided light level to know how dark it is
fmt.Println(?(?))
}
___

Create a free account to access the full topic