function finalPrice(price, dineIn) { // These were always used as a coefficients, no point in calculating 1 + tax every run const serviceModifier = 1.05, vatModifier = 1.1; const serviceCharge = dineIn ? serviceModifier * vatModifier : vatModifier; return Math.floor(price * serviceCharge); }
function finalPrice(price,dineIn) {const service = 0.05,vat = 0.1;const serviceCharge = dineIn ? (1+service)*(1+vat) : 1+vat;- function finalPrice(price, dineIn) {
- // These were always used as a coefficients, no point in calculating 1 + tax every run
- const serviceModifier = 1.05,
- vatModifier = 1.1;
- const serviceCharge = dineIn ? serviceModifier * vatModifier : vatModifier;
- return Math.floor(price * serviceCharge);
- }
function fun(message) { const leet = { a: '@', b: '8', c: '(', d: '|)', e: '3', f: '|=', g: '6', h: '#', i: '!', j: ']', k: '|{', l: '1', m: 'em', n: '[\]', o: '0', p: '|*', q: '0,', r: '|2', s: '$', t: '7', u: '(_)', v: '\/', w: 'vv', x: '%', y: '`/', z: '2', } return message.toLowerCase().split('').map(s => leet[s] || s).join(''); }
function fun(e) {var leet = {a: '@',b: '8',c: '(',d: '|)',e: '3',f: '|=',g: '6',h: '#',i: '!',j: ']',k: '|{',l: '1',m: 'em',n: '[\]',o: '0',p: '|*',q: '0,',r: '|2',s: '$',t: '7',u: '(_)',v: '\/',w: 'vv',x: '%',y: '`/',z: '2',}let message = e;let leetmsg = ''message = message.toLowerCase();for(var a of message) {if (leet[a]) {leetmsg += leet[a];} else {leetmsg += char;}}return leetmsg}- function fun(message) {
- const leet = {
- a: '@',
- b: '8',
- c: '(',
- d: '|)',
- e: '3',
- f: '|=',
- g: '6',
- h: '#',
- i: '!',
- j: ']',
- k: '|{',
- l: '1',
- m: 'em',
- n: '[\]',
- o: '0',
- p: '|*',
- q: '0,',
- r: '|2',
- s: '$',
- t: '7',
- u: '(_)',
- v: '\/',
- w: 'vv',
- x: '%',
- y: '`/',
- z: '2',
- }
- return message.toLowerCase().split('').map(s => leet[s] || s).join('');
- }
// TODO: Add your tests here // Starting from Node 10.x, [Mocha](https://mochajs.org) is used instead of our custom test framework. // [Codewars' assertion methods](https://github.com/Codewars/codewars.com/wiki/Codewars-JavaScript-Test-Framework) // are still available for now. // // For new tests, using [Chai](https://chaijs.com/) is recommended. // You can use it by requiring: // const assert = require("chai").assert; // If the failure output for deep equality is truncated, `chai.config.truncateThreshold` can be adjusted. var leet = { a: '@' , b: '8' , c: '(' , d: '|)' , e: '3' , f: '|=' , g: '6' , h: '#' , i: '!' , j: ']' , k: '|{' , l: '1' , m: 'em' , n: '[\]' , o: '0' , p: '|*' , q: '0,' , r: '|2' , s: '$' , t: '7' , u: '(_)' , v: '\/' , w: 'vv' , x: '%' , y: '`/' , z: '2' } describe("Solution", function() { it("should test for something", function() { Test.assertEquals(fun('string'), '$7|2![\]6'); Test.assertEquals(fun('Do you ever kumite?'), '|)0 `/0(_) 3/3|2 |{(_)em!73?'); }); });
- // TODO: Add your tests here
- // Starting from Node 10.x, [Mocha](https://mochajs.org) is used instead of our custom test framework.
- // [Codewars' assertion methods](https://github.com/Codewars/codewars.com/wiki/Codewars-JavaScript-Test-Framework)
- // are still available for now.
- //
- // For new tests, using [Chai](https://chaijs.com/) is recommended.
- // You can use it by requiring:
- // const assert = require("chai").assert;
- // If the failure output for deep equality is truncated, `chai.config.truncateThreshold` can be adjusted.
- var leet = {
- a: '@'
- , b: '8'
- , c: '('
- , d: '|)'
- , e: '3'
- , f: '|='
- , g: '6'
- , h: '#'
- , i: '!'
- , j: ']'
- , k: '|{'
- , l: '1'
- , m: 'em'
- , n: '[\]'
- , o: '0'
- , p: '|*'
- , q: '0,'
- , r: '|2'
- , s: '$'
- , t: '7'
- , u: '(_)'
- , v: '\/'
- , w: 'vv'
- , x: '%'
- , y: '`/'
- , z: '2'
- }
let message = "string";let leetmsg = ''message = message.toLowerCase();for(var a of message) {if (leet[a]) {leetmsg += leet[a];} else {leetmsg += char;}}- describe("Solution", function() {
- it("should test for something", function() {
Test.assertEquals(fun(message), leetmsg);Test.assertEquals(fun(message), leetmsg);- Test.assertEquals(fun('string'), '$7|2![\]6');
- Test.assertEquals(fun('Do you ever kumite?'), '|)0 `/0(_) 3/3|2 |{(_)em!73?');
- });
- });