From 1794f70837ea195d6e3600777f80d6838453696b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Allienne?= Date: Tue, 23 Jan 2018 22:27:42 +0100 Subject: [PATCH] solution: Add solution for proxies Close #9 --- exercises/proxies/exo.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/exercises/proxies/exo.js b/exercises/proxies/exo.js index 2cd763d..ef64993 100644 --- a/exercises/proxies/exo.js +++ b/exercises/proxies/exo.js @@ -1,5 +1,18 @@ let traps = { - /* votre solution ici */ + /* votre solution ici */ + set: function (target, prop, value) { + if (!isNaN(prop) && !target.includes(value)) { + target.push(value.toLowerCase()); + } + return true + }, + + get: function (target, prop) { + if (isNaN(prop)) { + return target[prop]; + } + return target[prop].replace(/\W/g, ''); + } }; module.exports = {traps};