From 72272476ff9733aa49c96342062b646ad6f981e1 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Fri, 4 Oct 2024 10:29:31 +0200 Subject: [PATCH] vinlotteri oppgave --- eloquentjavascript/06_Objects/obj.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/eloquentjavascript/06_Objects/obj.js b/eloquentjavascript/06_Objects/obj.js index 7970c3d..22fc489 100644 --- a/eloquentjavascript/06_Objects/obj.js +++ b/eloquentjavascript/06_Objects/obj.js @@ -13,3 +13,22 @@ whiteRabbit.speak("Oh my fur and whiskers"); hungryRabbit.speak("Got any carrots?"); +let finder = { + find(array){ + return array.some(v => v == this.value) + }, + value: 5 +}; +console.log(finder.find([4, 5])) +const array = [1, 2, 3, 4, 5]; + +// Checks whether an element is even +const even = (element) => element % 2 === 0; + +console.log(array.some(even)); + +let empty = { + name: "Geir", + age: 51, +}; +console.log(empty.age.toLocaleString(), ++empty.age); \ No newline at end of file