diff --git a/src/index.js b/src/index.js index abce2aa..9bc6fe8 100644 --- a/src/index.js +++ b/src/index.js @@ -2,14 +2,16 @@ function toVal(mix) { var k, y, str=''; if (typeof mix === 'string' || typeof mix === 'number') { - str += mix; - } else if (typeof mix === 'object') { + return mix; + } + + if (typeof mix === 'object') { if (Array.isArray(mix)) { - for (k=0; k < mix.length; k++) { - if (mix[k]) { - if (y = toVal(mix[k])) { + for (y=0; y < mix.length; y++) { + if (mix[y]) { + if (k = toVal(mix[y])) { str && (str += ' '); - str += y; + str += k; } } } diff --git a/test/index.js b/test/index.js index b4e6b2f..3b67335 100644 --- a/test/index.js +++ b/test/index.js @@ -15,6 +15,11 @@ test('strings', t => { t.end(); }); +test('numbers', t => { + t.equal(fn(123, 456), '123 456'); + t.end(); +}); + test('strings (variadic)', t => { t.is(fn(''), ''); t.is(fn('foo'), 'foo');