diff --git a/difference.js b/difference.js index ba76f72..e9254cf 100644 --- a/difference.js +++ b/difference.js @@ -1,4 +1,8 @@ function difference(array, values) { + if (!Array.isArray(array) || !Array.isArray(values)) { + throw new Error('배열 정보를 입력하세요!'); + } + const newArray = array.filter((item) => !values.includes(item)); return newArray; } diff --git a/last.js b/last.js new file mode 100644 index 0000000..c1fca1a --- /dev/null +++ b/last.js @@ -0,0 +1,11 @@ +function last(array) { + if (!Array.isArray(array)) { + throw new Error('배열 정보를 입력하세요!'); + } + + if (array.length === 0) { + return undefined; + } else { + return array[array.length - 1]; + } +} diff --git a/tempCodeRunnerFile.js b/tempCodeRunnerFile.js new file mode 100644 index 0000000..8bd9e94 --- /dev/null +++ b/tempCodeRunnerFile.js @@ -0,0 +1 @@ +return undefined; \ No newline at end of file