Stupid Addition

Published by Matt in

Create a function that takes two parameters and, if both parameters are strings, add them as if they were integers or if the two parameters are integers, concatenate them.

Examples

stupid_addition(1, 2) ➞ "12"

stupid_addition("1", "2") ➞ 3

stupid_addition("1", 2) ➞ nil

Notes

  • If the two parameters are different data types, return nil.
  • All parameters will either be strings or integers.
Watch a quick demo on how Edabit works.