[JS Practice] arithmetic list

Title :

Arithmetic list


Function accept three parameters :

  • first the first term in the sequence
  • c the constant that you are going to add ( since it is an arithmetic sequence…)
  • l the number of terms that should be returned

Sequence in wikipedia: Sequence


seqlist(0, 1, 5); // must return [0, 1, 2, 3, 4]

My solution :

function seqlist(first,c,l){
  var arr = [];
  for(i=0; i<l; i++) {
    arr.push(first + i * c);
  return arr;

Ref. from codewars


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s