본문 바로가기

전체 글46

[CodeWars] 8kyu#4 - Square(n) Sum [CodeWars] 8kyu#4 - Square(n) Sum ■ Description:Complete the squareSum method so that it squares each number passed into it and then sums the results together. For example:squareSum([1, 2, 2]); // should return 9 ■ Qustion:function squareSum(numbers){ } ■ My Solution:1234567function squareSum(numbers){ var a = numbers[0]+numbers[1]; var b = numbers[2]; var powReturn =0; powReturn = Math.pow(a,b).. 2016. 5. 28.
[CodeWars] 8kyu#3 - Get Planet Name By ID [CodeWars] 8kyu#3 - Get Planet Name By ID ■ Description:The function is not returning the correct values. Can you figure out why? getPlanetName(3); // should return 'Earth' ■ 문제1234567891011121314151617181920212223function getPlanetName(id){ var name; switch(id){ case 1: name = 'Mercury' case 2: name = 'Venus' case 3: name = 'Earth' case 4: name = 'Mars' case 5: name = 'Jupiter' case 6: name = '.. 2016. 5. 28.
[CodeWars] 8kyu#2 - Return to Sanity [CodeWars] 8kyu#2 - Return to Sanity ■ InstructionsThis function returns something strange. What's wrong? ■ 문제123456function mystery() { var results = {sanity: 'Hello'}; return results;}cs ■ My Solution1234function mystery() { var results = {'sanity': 'Hello'}; return results['sanity'];}Colored by Color Scriptercs ■ 풀이'객체'을 알면 풀린다 > 참고 : 생활코딩 - 자바스크립트 '객체' 2016. 5. 25.
[생활코딩] javascript - 객체 본 강의 학습은 [생활코딩]를 통하여 학습하고 있습니다. JavaScript - 객체 (1/3) : 객체의 문법지금까지 살펴본 배열은 아이템에 대한 식별자로 숫자를 사용데이터가 추가되면 배열 전체에서 중복되지 않는 인덱스가 자동으로 만들어져서 추가된 데이터에 대한 식별자가 된다. 이 인덱스를 이용해서 데이터를 가져오게 되는 것이다. 만약 인덱스로 문자를 사용하고 싶다면 객체(dictionary)를 사용해야 한다. 다른 언어에서는 연관배열(associative array) 또는 맵( map), 딕셔너리(Dictionary)라는 데이터 타입이 객체에 해당한다. - 객체의 생성var grades = {'egoing': 10, 'k8805': 6, 'sorialgi': 80};: egoing은 key가 되고, .. 2016. 5. 25.