Problem solution of CodeWare

function createFebonacci(nth){  
  return Math.round((Math.pow(1.6180339, nth))/Math.sqrt(5));  
}

function createEvenFebonacci() {
  var nth = 0;
  var febo = 0;
  var result = 0
  var suquence = [];
  while(1) {
    febo = createFebonacci(nth++);
    console.log(febo);
    if (febo % 2 == 0) {
      suquence.push(febo);
    }
    if (febo > 4000000) {
      console.log(suquence);
	for (var i = 0; i < suquence.length; i++) {
	    result += sesuquence[i];				
	}	
      break;
    }
  }
   console.log(result);
}
createEvenFebonacci();



var capitals = function (word) {
	var indexs = [];
  for (i = 0; i < word.length; i++ ) {
    var charcter = word[i];
    if (charcter == word[i].toUpperCase()) {
      indexs.push(i);
    }
  }
  return indexs;
};






function Counter(){
  this.value = 0;
}

Counter.prototype.incr = function() {
  this.value++;
}

Counter.prototype.toString = function() {
  return this.value;
}



function isIsogram(str) {
  var charcters = [];
  for (var i = 0; i < str.length; i++) {
    if (typeof charcters[str.toUpperCase().charCodeAt(i)] == 'undefined')
        charcters[str.toUpperCase().charCodeAt(i)] = str[i]
    else 
      return false;        
  }
  return true;  
}



Implement function createTemplate which takes string with tags wrapped in {{brackets}}
as input and returns closure, which can fill string with data (flat object, where keys are tag names).

let personTmpl = createTemplate("{{name}} likes {{animalType}}");
personTmpl({ name: "John", animalType: "dogs" }); // John likes dogs

function createTemplate(template) {     
  
  return function(obj) {

    for (attr in obj) {      
      var pattern = new RegExp('{{' + attr + '}}', "g");      
      var matchText = pattern.test(template) ? obj[attr] : '' ;
      console.log(matchText);
      template = template.replace(pattern,matchText );             
    }        
    
    return template;
  }
}

var personTmpl = createTemplate("{{name}} likes {{animalType}}");
personTmpl({ names: "John", animalType: "dogs" }); // John likes dogs

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.


//an = a1 + (n - 1)d
//Sn = (n/2)(a1 + an)

function solution(number){  
    return getSum(3, number -1 ) + getSum(5, number- 1) + getSum(15, number- 1);
}
    
function getSum(difference,number) {  
  var frequency = Math.floor(number / difference);  
  var lastNumber = difference + (frequency - 1) * difference;
  return (frequency/ 2) * (difference + lastNumber);
}    

solution(19)