Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pad an Array

In this challenge, you'll want to write a method pad. It will accept a list, a minimum size (non-negative integer) for the list, and an optional argument of what the list should be "padded" with (see the example with "apple" below).

If the list's length is less than the minimum size, pad should return a new list padded with the pad value up to the minimum size.

For example,

pad([1,2,3], 5)

should return

[1,2,3,None,None]

And

pad([1,2,3], 5, 'apple')

should return

[1,2,3,'apple', 'apple']

If the minimum size is less than or equal to the length of the list, it should just return the list. That is, pad([1,2,3], 3) should return [1,2,3]. pad(my_array, 0) should always return a list equal to my_array.

Remember to write tests!

JS Usage

cd js
npm install
node padArraySpec.js 

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages