Search⌘ K
AI Features

Challenge: Validate Arguments

Explore how to validate arguments within a JavaScript function by checking if inputs are defined and of string type. This lesson helps you implement robust error handling for incorrect or missing arguments using TypeError, ensuring safe string concatenation. You will gain practical skills in input validation that are critical for interviews and real-world JavaScript coding.

Problem statement #

The concat function takes two strings and adds them together. Your task includes implementing this functionality and validating the function arguments as well. You need to check for the following cases:

  • Case 1: is string1 defined?

  • Case 2: is string2 defined?

  • ...