<commit_before><commit_msg>Add to week 7 exercises<commit_after>// Separate Numbers with Commas in JavaScript **Pairing Challenge**


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

// Pseudocode
// input an integer
// output a string of the integer with commas
  
 
// steps

// define a function that accepts an integer as     argument
// convert to array 
// //reverse
// separate digits
// add comma every 4th character starting from the end of the string


// var reverseString = function(str) {
//   var newString = "";
//   for (var i = str.length-1; i >= 0; i--) {
//     newString = newString.concat(charAt(i));
//   }
// }

// reverseString("Does this work?");
// Initial Solution

var commas = function(num) {
  var testArray = num.toString().split("");
  //console.log(testArray) 
     for (var i = testArray.length-3; i > 0; i -= 3) {
    testArray.splice(i, 0, ",");

  }; 
  console.log(testArray.join(""));
}

commas(303945123)
// // var array = [1,2,3,4,5];
// // console.log(array);
// commas(12345);


 
 
//console.log(arr[2]);
// Refactored Solution



//     

// Your Own Tests (OPTIONAL)




// Reflection
{'fraction_non_alphanumeric': 0.16429840142095914, 'fraction_numerical': 0.02486678507992895, 'mean_word_length': 2.683006535947712, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '4473901', 'n_tokens_mistral': 399, 'n_tokens_neox': 365, 'n_words': 111}