본문 바로가기

2016/0535

[CodeWars] 8kyu#7 - Short Long Short [CodeWars] 8kyu#7 - Short Long Short ■ Description: Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length0). solution("1", "22") // returns "1221"solution("22", "1") // returns "1221"solution("1", "22") // returns "1221"solution("22".. 2016. 5. 30.
[CodeWars] 8kyu#6 - Multiply [CodeWars] 8kyu#6 - Multiply ■ Description:The code does not execute properly. Try to figure out why. ■ Qustion:123function multiply(a, b){ a * b}cs ■ My Solution:123function multiply(a, b){ return a * b;}cs ■ 추가function에서 return을 할 수가 없다!!var aaa = multiply(3,4); console.log(aaa); // 화면에 출력alert(aaa); // 경고창으로 출력 2016. 5. 29.
[CodeWars] 8kyu#5 - Broken Greetings [CodeWars] 8kyu#5 - Broken Greetings ■ Description:Correct this code, so that the greet function returns the expected value. ■ Question:1234567function Person(name){ this.name = name;} Person.prototype.greet = function(otherName){ return "Hi " + otherName + ", my name is " + name;}Colored by Color Scriptercs 솔직히.. 뭘 어떻게 하라는건지.. 했다.이번 문제를 풀기 위해서는 생성자 함수와 프로토타입이란 개념이 필요하다.공부하자!! ■ Solution:1234567.. 2016. 5. 29.
[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.