<commit_before>// Separate Numbers with Commas in JavaScript **Pairing Challenge**

// I worked on this challenge with: <NAME>..

// Pseudocode
// create a function that accepts an integer
//    doesn't change the integer under 1000
//    convert argument to string
//    split string into array
//    reverse array
//    split myArray into arrays of 3
//    reverse array and join into an integer
// close the function

// Initial Solution
function separateComma(i) {
  var myArray = [];
  var subArray = [];
  var counter = 3;
  if (i < 1000) {
    return i;
  }
  else {
    i = i.toString()
    myArray = i.split('')
    myArray = myArray.reverse()
    while (counter < myArray.length) {
      myArray.splice(counter, 0, ",");
      counter += 4
    }
 //   for (var index = 0; index < myArray.length; index += 2) {
  //    myArray.splice(0, 3, ",")
  //  }
  }
  return myArray.reverse().join("")
}


// Refactored Solution

function separateComma(i) {
  var myArray = [];
  var counter = 3;
  if (i < 1000) {
    return i;
  }
  else {
    myArray = i.toString().split('').reverse()
    while (counter < myArray.length) {
      myArray.splice(counter, 0, ",")
      counter += 4
    }
    return myArray.reverse().join("")
  }
}



// Your Own Tests (OPTIONAL)

console.log(separateComma(123456789))
console.log(separateComma(1234567890))
console.log(separateComma(12345678923))
console.log(separateComma(123456789123))

// Reflection<commit_msg>Complete refactor<commit_after>// Separate Numbers with Commas in JavaScript **Pairing Challenge**

// I worked on this challenge with: <NAME>..

// Pseudocode
// create a function that accepts an integer
//    doesn't change the integer under 1000
//    convert argument to string
//    split string into array
//    reverse array
//    split myArray into arrays of 3
//    reverse array and join into an integer
// close the function

// Initial Solution
function separateComma(i) {
  var myArray = [];
  var subArray = [];
  var counter = 3;
  if (i < 1000) {
    return i;
  }
  else {
    i = i.toString()
    myArray = i.split('')
    myArray = myArray.reverse()
    while (counter < myArray.length) {
      myArray.splice(counter, 0, ",");
      counter += 4
    }
  return myArray.reverse().join("")
}


// Refactored Solution

function separateComma(i) {
  var myArray = [];
  if (i < 1000) {
    return i;
  }
  else {
    myArray = i.toString().split('').reverse()
    for (var index = 3; index < myArray.length; index += 4) {
      myArray.splice(index, 0, ",");
      }
    return myArray.reverse().join("");
    }
  }
}



// Your Own Tests (OPTIONAL)

console.log(separateComma(123456789))
console.log(separateComma(1234567890))
console.log(separateComma(12345678923))
console.log(separateComma(123456789123))

// Reflection
/*
What was it like to approach the problem from the perspective of JavaScript? Did you approach the problem differently?

Our approach to the problem was the same but we did have issues writing the problem. We wrote our

What did you learn about iterating over arrays in JavaScript?



What was different about solving this problem in JavaScript?



What built-in methods did you find to incorporate in your refactored solution?



*/
{'fraction_non_alphanumeric': 0.12364425162689804, 'fraction_numerical': 0.039045553145336226, 'mean_word_length': 2.9558823529411766, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2320488', 'n_tokens_mistral': 1113, 'n_tokens_neox': 990, 'n_words': 325}