← Back to challenges

Stupid Addition

JavaScriptHardvalidationstringsnumbersconditions

Instructions

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

stupidAddition(1, 2) ➞ "12"

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

stupidAddition("1", 2) ➞ null

Notes

  • If the two parameters are different data types, return null.
  • All parameters will either be strings or integers.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Formatting Text on Innokodakademija