CodeWars: Defuse The Bombs Solution
1console.log(Object.keys(Bomb))23// 104console.log(Bomb.diffuse.toString())5Bomb.diffuse(Bomb.key)67// 98console.log(Bomb.hint)9console.log(Bomb.diffuse.toString())10while (Bomb.hint === "just keep trying") {11 Bomb.diffuse(Bomb.key)12}13console.log("\n\n")1415// 816console.log(Bomb.hint)17console.log(Bomb.diffuse.toString())18Bomb.diffuse(this.BombKey)19console.log("\n\n")2021// 722console.log(Bomb.hint)23console.log(Bomb.diffuse.toString())24function diffuseTheBomb() {25 return true26}27Bomb.diffuse()28console.log("\n\n")2930// 631console.log(Bomb.hint)32console.log(Bomb.diffuse.toString())33console.log(34 Buffer.from("VGhlIGtleSBpcyAiMy4xNDE1OSI=", "base64").toString("utf-8")35)36Bomb.diffuse(3.14159)37console.log("\n\n")3839// 540console.log(Bomb.hint)41console.log(Bomb.diffuse.toString())42const date = new Date()43date.setFullYear(date.getFullYear() - 4)44Bomb.diffuse(date)45console.log("\n\n")4647// 448console.log(Bomb.hint)49console.log(Bomb.diffuse.toString())50Bomb.diffuse(Object.freeze({ key: 43 }))51console.log("\n\n")5253// 354console.log(Bomb.hint)55console.log(Bomb.diffuse.toString())56Bomb.diffuse({57 applied: false,58 valueOf: function () {59 let val = !this.applied ? 9 : 1160 this.applied = true61 return val62 },63})64console.log("\n\n")6566// 267console.log(Bomb.hint)68console.log(Bomb.diffuse.toString())69const MathRandom = Math.random70Math.random = function () {71 return {72 valueOf: () => {73 let val = !this.applied ? 0.5 : 174 this.applied = true75 return val76 },77 }78}79Bomb.diffuse(42)80Math.random = MathRandom81console.log("\n\n")8283// 184console.log(Bomb.hint)85console.log(Bomb.diffuse.toString())86Array.prototype.valueOf = function () {87 return this.reduce((acc, el) => acc + el, 0)88}89Bomb.diffuse(Buffer.from("yes", "ascii").toString("base64"))90console.log("\n\n")
Comments
Loading comments...
Tags
codewars
Apply and earn a $2,500 bonus once you're hired on your first job!
Clients from the Fortune 500 to Silicon Valley startups
Choose your own rate, get paid on time
From hourly, part-time, to full-time positions
Flexible remote working environment
A lot of open JavaScript jobs!!
Fact corner: Referred talent are 5x more likely to pass the Toptal screening process than the average applicant.
Still hesitate? Read HoningJS author's guide on dealing with Toptal interview process.