Joined April 2016
·

shinjukudev

Metaps
·
Tokyo
·

Posted to Remove Element (JS Algorithm) over 1 year ago

I noticed that if the first integer in the array matches the integer to be removed, for instance:

var int = 3;
var arr = [3,1,2,3];

The array will be returned as follows, with an empty string at index arr[0]:

["","1","2"]

This case is also different than expected:

var int = 3;
var arr = [2,2,23333,2];

returns:

["2","2","2","2"]

I was expecting the returned array to equal 2,2,23333,2] So I think this is simply a matter of a different interpretation of the problem.

Posted to Remove Element (JS Algorithm) over 1 year ago

@jeffcheung Thanks again for the great feedback. I learned a new way of working with reg-ex patterns from your example.

Yes, the return arr.length was unintended. Fixed the typo now

Posted to Vowel Count (JS Algorithm) over 1 year ago

@jeffcheung In that case, we can get rid of var count = 0 as well :)

Posted to Vowel Count (JS Algorithm) over 1 year ago

@jeffcheung Hey! Thanks for the feedback! That's a really good point

Achievements
1 Karma
2,834 Total ProTip Views
Interests & Skills