본문 바로가기
Happly Coding/CodeWars

[CodeWars] 8kyu#9 - Basic Training: Add item to an Array

by Hello Do. 2016. 6. 6.

[CodeWars] 8kyu#9 - Basic Training: Add item to an Array


■ Description:

Add the value "codewars" to the websites array.

After your code executes the websites array should == ["codewars"]


The websites array has already been defined for you using the following code:

var websites = [];


■ Qustion

// add the value "codewars" to the already defined websites array



■ My Solution

....?


■ Best Solution

websites.push('codewars');


에잇!!!!!!! 배열 추가 문제 였음.


w3schools.com :: JavaScript Array push() Method

1
2
3
4
5
6
7
8
Example
Add a new item to an array:
 
var fruits = ["Banana""Orange""Apple""Mango"];
fruits.push("Kiwi");
The result of fruits will be:
 
Banana,Orange,Apple,Mango,Kiwi
cs



'Happly Coding > CodeWars' 카테고리의 다른 글

[CodeWars] 8kyu#8 - Shifty Closures  (0) 2016.06.06
[CodeWars] 8kyu#7 - Short Long Short  (0) 2016.05.30
[CodeWars] 8kyu#6 - Multiply  (0) 2016.05.29
[CodeWars] 8kyu#5 - Broken Greetings  (0) 2016.05.29
[CodeWars] 8kyu#4 - Square(n) Sum  (0) 2016.05.28