Created
January 7, 2017 06:52
-
-
Save torpedo87/f3548334eeef33b51cd1b1997e62727f to your computer and use it in GitHub Desktop.
1~7번 숙제
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. 홀수 출력 | |
function getOdd(n){ | |
var i = 0; | |
while (i < n) { | |
i++; | |
if(i%2===0){ | |
continue; | |
}console.log(i); | |
} | |
}; | |
//2. 사각형 넓이 | |
var multiply=1 | |
function getRectArea(){ | |
for(var i=0; i<arguments.length; i++){ | |
multiply=multiply*arguments[i]; | |
} | |
console.log(multiply); | |
}; | |
//3. 감각형 넓이 | |
var multiply=1 | |
function getTriangleArea(){ | |
for(var i=0; i<arguments.length; i++){ | |
multiply=multiply*arguments[i]; | |
var result=multiply/2 | |
} | |
console.log(result); | |
}; | |
//4. 사각형과 삼각형 넓이 반환 | |
var multiply=1 | |
function getArea(){ | |
for(var i=0; i<arguments.length; i++){ | |
multiply=multiply*arguments[i]; | |
var result1=multiply; | |
var result2=multiply/2; | |
var total=[result1,result2] | |
}; | |
console.log(total); | |
}; | |
//5. 검색어 리스트 변경 | |
var recentSearchWord=["코드스쿼드","자바스크립트"]; | |
function addWord(arry,strg){ | |
arry.push(strg); | |
}; | |
function removeWord(arry,strg){ | |
arry.splice(arry.indexOf(strg),1); | |
}; | |
//6. 삽입 함수 만들기 | |
var myFriends=["hary","john","rock"] | |
function insertElement(arry,num,strg){ | |
arry.splice(num,0,strg); | |
}; | |
//7. 예습 | |
myObj.name, myObj['name'] | |
myObj.name='codemaster' , myObj['name']='codemaster' | |
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}; | |
delete person.age; // or delete person["age"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment