Skip to content

Commit

Permalink
refactor: add array check
Browse files Browse the repository at this point in the history
  • Loading branch information
FrontKid committed Aug 3, 2023
1 parent ca9339f commit eb94bdb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/arrayMethodJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const isNotIgnoredEl = (el) => ![null, undefined].includes(el);
function applyCustomJoin() {
[].__proto__.join2 = function(separator = ',') {
const currentArray = this;

if (!(currentArray instanceof Array)) {
return '';
}

const INDEX_OF_LAST_ELEMENT = currentArray.length - 1;

let concatedString = '';
Expand Down

0 comments on commit eb94bdb

Please sign in to comment.