Number Switch Challenge 5,7

// If you haven't solved it, please do so before checking the answer.



[SerializeField] private int number;



    private void Start()

    {

        Debug.Log(AlternateNumber(number));

    }



    // Return 5 if inputNumber is 7 and 7 if inputNumber is 5

    // Constraints: No loops, if statements, conditions, ternary operators, or switches

    private int AlternateNumber(int inputNumber)

    {

        return 5 + (7 - inputNumber);

    }

Comments

Popular Posts