Skip to content

Commit

Permalink
Tugas Quiz Day 3
Browse files Browse the repository at this point in the history
  • Loading branch information
kaysypy committed May 30, 2022
0 parents commit c2a9dd1
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}
13 changes: 13 additions & 0 deletions FindYear.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Remember, the Date constructor takes a zero-based month number, so a
// month value of 10 corresponds to the eleventh month, November
const dates = [new Date(2021, 10, 20), new Date(2020, 3, 12),
new Date(2020, 5, 23), new Date(2022, 3, 18)];
// Find the first date in 2020
/* const matchingDate = dates.find(date => date.getFullYear() === 2020);
console.log(matchingDate); */

function matchingDate (dates, year){
return dates.find(date => date.getFullYear() === year);
}

console.log(matchingDate(dates,2020));//Sun Apr 12 2020 00:00:00 GMT+0700 (Western Indonesia Time)
8 changes: 8 additions & 0 deletions MaxNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const numbers = [44,131,335,223,21,66,87];
// This syntax is not allowed. The result is NaN.

function maxNumber(arrays){
return Math.max(...numbers)
}

console.log(maxNumber(numbers));
15 changes: 15 additions & 0 deletions SliceEmp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// terdapat array employees
const cities = ["merak", "tangerang", "jakarta", "bogor", "cianjur", "cimahi", "bandung"];

const bogor = cities.indexOf("bogor")

const citiesSliced = [...cities.slice(0, bogor), ...cities.slice(bogor + 1)]

function citiesSlice(arrays, cityBetween) {
const jakarta=arrays.indexOf(cityBetween);
const citiesSliced2 = [...arrays.slice(0, jakarta), ...arrays.slice(jakarta + 1)]
return citiesSliced2;
}

console.log(citiesSlice(cities,"jakarta"));
//['merak', 'tangerang', 'bogor', 'cianjur', 'cimahi', 'bandung']

0 comments on commit c2a9dd1

Please sign in to comment.