diff --git a/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 4be61e58ab8..b9ff84a0abb 100644 --- a/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -239,7 +239,7 @@ Value ArrayPrototype::join(Interpreter& interpreter) return {}; String separator = ","; - if (interpreter.argument_count() == 1) { + if (interpreter.argument_count()) { separator = interpreter.argument(0).to_string(interpreter); if (interpreter.exception()) return {}; diff --git a/Libraries/LibJS/Tests/Array.prototype.join.js b/Libraries/LibJS/Tests/Array.prototype.join.js index 0221aacfd39..fc82deb20cc 100644 --- a/Libraries/LibJS/Tests/Array.prototype.join.js +++ b/Libraries/LibJS/Tests/Array.prototype.join.js @@ -5,6 +5,7 @@ try { assert(["hello", "friends"].join() === "hello,friends"); assert(["hello", "friends"].join(" ") === "hello friends"); + assert(["hello", "friends", "foo"].join("~", "#") === "hello~friends~foo"); assert([].join() === ""); assert([null].join() === ""); assert([undefined].join() === "");