str.padStart is not a function


#1

The spec shows this to be supported in all browsers as of ES2017 yet the Lodash project reports that it is not a function. Does this have something to do with the JS that is behind the CC composer interface?

Seems kind of strange that it would not be supported. Works fine in Chrome.

pad = (str, len) => {
   n = str.length;
   if (len <= n) {
     return str;
   }
   m = Math.floor((len - n) / 2);
   str = str.padStart(m + n);
   return str.padEnd(len);
 }
pad('my string', 18)
"    my string     "

At any length, there were solutions before 2017 and we just have to revert to those.

Anyone who has completed this module can run a one-time test all for a final cumulative result.

$ node test/test-all.js                                               
_.chunk() Tests:                                                      
1 - _.chunk() is defined - Passed!                                    
2 - Returns an array - Passed!                                        
3 - Chunks evenly-divided arrays - Passed!                            
4 - Chunks unevenly-divided arrays - Passed!                          
_.clamp() Tests:                                                      
1 - _.clamp() is defined - Passed!                                    
2 - Returns in-range values unclamped - Passed!                       
3 - Clamps values by lower bound - Passed!                            
4 - Clamps values by upper bound - Passed!                            
_.dropWhile() Tests:                                                  
1 - _.dropWhile() is defined - Passed!                                
2 - Returns an array - Passed!                                        
3 - Drops elements until predicate function returns falsy - Passed!   
_.drop() Tests:                                                       
1 - _.drop() is defined - Passed!                                     
2 - Returns an array - Passed!                                        
3 - Drops the specified number of elements from the beginning of an array - Passed!                                                         
4 - Drops one element if no number is specified - Passed!             
_.findKey() Tests:                                                    
1 - _.findKey() is defined - Passed!                                  
2 - Returns the corresponding key of a value that returns truthy from the predicate function - Passed!                                      
3 - Returns undefined if an object has no values that return truthy from the predicate function - Passed!                                   
_.has() Tests:
1 - _.has() is defined - Passed!
2 - Returns true if an object has a value at a specified key - Passed!
3 - Returns false if an object does not have a value at a specified key - Passed!
_.inRange() Tests:
1 - _.inRange() is defined - Passed!
2 - Returns true if an in-range value is in range - Passed!
3 - Returns false if a too small value is out of range - Passed!
4 - Returns false if a too large value is out of range - Passed!
5 - Uses end value as start value and start value as 0 if end value is not defined - Passed!
6 - Reverses start and end values if start is bigger than end - Passed!
_.invert() Tests:
1 - _.invert() is defined - Passed!
2 - Returns an object with all keys and values inverted - Passed!
3 - Returns an object with all keys and values inverted - Passed!
_.pad() Tests:
1 - _.pad() is defined - Passed!
2 - Returns evenly-padded strings - Passed!
3 - Returns oddly-padded strings with extra padding on right side - Passed!
4 - Returns strings longer than provided length un-padded - Passed!
_.words() Tests:
1 - _.words() is defined - Passed!
2 - Returns an array - Passed!
3 - Returns an array of words from a string with one word - Passed!
4 - Returns an array of words from a string with two words - Passed!
5 - Returns an array of words from a string with three words - Passed!