자바스크립트

Visual Studio Code 자바스크립트 터미널 콘솔 출력

양상추상츄 2022. 3. 9. 20:15
 

Visual Studio Code 자바스크립트 실행 확인 가능하도록 추가 설치

자바스크립트를 Visual Studio Code를 이용하여 작성하였을 때 제대로 작성되었는지 확인을 하기 위해 추가로 Node.js를 설치해야 합니다. Node.js의 설치 파일 다운로드 방법과 설치 방법에 대해 알아보

mr-johndoe.tistory.com

node.js가 설치된 상태에서 JavaScript Debug Terminal을 클릭하여 아래와 같이 실행을 해보았다.

 

// Your mission here is to create a function that gets an array and returns a tuple with 3 elements 
//- the first, third and second element from the last for the given array.

// Input: A tuple, at least 3 elements long.

// Output: A tuple.

// Example:

easyUnpack([1, 2, 3, 4, 5, 6, 7, 9]) == [1, 3, 7]
easyUnpack([1, 1, 1, 1]) == [1, 1, 1]
easyUnpack([6, 3, 7]) == [6, 7, 3]


function easyUnpack(elements) {
    return [elements[0], elements[2], elements[elements.length - 2]];
}

console.log('Example:');
console.log(easyUnpack([1, 2, 3, 4, 5, 6, 7, 9]));