Created
January 7, 2017 07:30
-
-
Save pycraft114/10cc8318f79db01a2edb44e2f819ed8a to your computer and use it in GitHub Desktop.
assignment
This file contains hidden or 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
//--------------Returns odd numbers--------------------------------------------- | |
function printOdd(number){ | |
var i = 0; | |
var oddNum = []; | |
while (i <= number){ | |
if (i % 2 === 1){ | |
oddNum.push(i); | |
i++; | |
}else { | |
i++; | |
continue; | |
}; | |
}; | |
console.log(oddNum); | |
}; | |
//-----------returns area of square--------------------------------------------- | |
function getArea(length,width){ | |
var area = length * width; | |
return area; | |
}; | |
//-------------------returns area of triangle----------------------------------- | |
function getTriarea(base,height){ | |
var area = base * height / 2; | |
return area; | |
}; | |
//-----------------returns area of triangle and square-------------------------- | |
function getArea(base,height){ | |
var squareArea = base * height; | |
var triArea = base * height / 2; | |
return [squareArea,triArea]; | |
}; | |
//-------------------adding and removing word function------------------------- | |
function addWord(recentSearchWord,wordToAdd){ | |
recentSearchWord.push(wordToAdd); | |
return recentSearchWord; | |
}; | |
function removeWord(recentSearchWord,wordToRemove){ | |
var index = recentSearchWord.indexOf(wordToRemove); | |
recentSearchWord.splice(index,1); | |
return recentSearchWord; | |
}; | |
//-------------------inserting value function---------------------------------- | |
function insertElement(list,index,wordToInsert){ | |
list.splice(index,0,wordToInsert); | |
}; | |
//------------------answers to the questions----------------------------------- | |
/* | |
1.myObj.name 과 myObj["name"] 두가지 방법으로 myObj의 키값인 name에 접근할수 있다. | |
2.myObj.name = 수정할 value 혹은 myObj["name"] = 수정할 value를 통해 수정 할 수 있다. | |
3.새로운 key와 value를 추가하고 싶을 경우 | |
myObj.newKey = newValue 혹은 myObj[newKey] = newValue를 통해 추가 할 수 있다. | |
4.delete myObj.keyTodelete 를 통해 key와 value를 삭제 할 수 있다. | |
5.method들을 필요에 따라 call 할 수 있으며, 필요한 경우 상속받는 객체의 prototype에 접근함으로써 | |
method를 사용할 수 도 있다. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment