title: Adding two string arguments in Node Addons
body: <p>I am trying to add two string arguments in my addon but I could not get it to work. I always get an error about the types of the two arguments.</p>
  <p>My function:</p>
  <pre><code>void Add(const FunctionCallbackInfo&lt;Value&gt;&amp; args) {
    Isolate* isolate = args.GetIsolate();
    Local&lt;Context&gt; context = isolate-&gt;GetCurrentContext();
  
    // Check the number of arguments passed.
    if (args.Length() &lt; 2) {
      isolate-&gt;ThrowException(Exception::TypeError(
          String::NewFromUtf8(isolate, &quot;Wrong number of arguments&quot;)
              .ToLocalChecked()));
      return;
    }
  
    // Check the argument types
    if (!args[0]-&gt;IsString() || !args[1]-&gt;IsString()) {
      isolate-&gt;ThrowException(Exception::TypeError(
          String::NewFromUtf8(isolate, &quot;Wrong arguments&quot;).ToLocalChecked()));
      return;
    }
  
    Local&lt;String&gt; arg1 = args[0]-&gt;ToString(context).ToLocalChecked();
    Local&lt;String&gt; arg2 = args[1]-&gt;ToString(context).ToLocalChecked();
  
    args.GetReturnValue().Set(arg1 + arg2);
  }
  </code></pre>
  <p>The Whole File:</p>
  <pre><code>#include &lt;node.h&gt;
  #include &lt;string&gt;
  
  namespace demo {
  
  using v8::Context;
  using v8::Exception;
  using v8::FunctionCallbackInfo;
  using v8::Isolate;
  using v8::Local;
  using v8::Number;
  using v8::Object;
  using v8::String;
  using v8::Value;
  
  void Add(const FunctionCallbackInfo&lt;Value&gt; &amp;args) {...
  
  void Init(Local&lt;Object&gt; exports) { NODE_SET_METHOD(exports, &quot;add&quot;, Add); }
  
  NODE_MODULE(NODE_GYP_MODULE_NAME, Init);
  
  }
  </code></pre>
  <p>Any feedback would be appreciated.</p>