:star2: 1385 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
:warning: could not find receiver for armynational
:cookie: 304 | @asparism |http://www.freecodecamp.com/asparism
:star2: 1386 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
function getCount(str) {
var vowelsCount = 0;
str.split(' ')
switch (str){
case "a": vowelsCount + 1;
break;
case "e": vowelsCount + 1;
break;
case "i": vowelsCount + 1;
break;
case "o": vowelsCount + 1;
break;
case "u": vowelsCount + 1;
break;
};
return vowelsCount;
}
var arr = [
[0,0,0]
];
var x=[...arr, [1,1,1,]]
console.log(x)//[ [ 0, 0, 0 ], [ 1, 1, 1 ] ]
x[0][0]=1;
console.log(x)//[ [ 1, 0, 0 ], [ 1, 1, 1 ] ]
console.log(arr)//[ [ 1, 0, 0 ] ]---> why use spread operator, the arr element is still changed?
var arr = [
[0,0,0]
];
var x=arr.concat([[1,1,1]]);
console.log(x)//[ [ 0, 0, 0 ], [ 1, 1, 1 ] ]
x[0][0]=1;
console.log(x)//[ [ 1, 0, 0 ], [ 1, 1, 1 ] ]
console.log(arr)//[ [ 1, 0, 0 ] ]---> why use concat, the arr element is still changed?
arr
changes when you're only updating x
?
why the original arr changes when you're only updating x?
c0d0er sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
var copyOfMyArray = myArray.slice(0);
function getCount(str) {
var sum=0
var i = str.split(");
switch (i){
case 'a': sum + 1;
break;
case 'e': sum +1;
break;
case 'i': sum + 1;
break;
case 'o': sum + 1;
break;
case 'u': sum + 1;
break;
};
return sum
}
:warning: c0d0er already gave tylermoeller points