Write a function caesar() that will return the input message with each character shifted to the right n times in the alphabet. Make sure the encoded message is in all caps since the Romans didn't use lowercase letters. Only punks use lowercase letters.
Example : 'James is the greatest at kumite!' => 'MDPHV LV WKH JUHDWHVW DW NXPLWH!'
Make sure to preserve the spaces and punctuation of the original message, you know, for clarity's sake.
// Description:
// Write a function caesar() that will return the input message with each character
// shifted to the right n times in the alphabet. Make sure the encoded message is in
// all caps since the Romans didn't use lowercase letters. Only punks use lowercase letters.
// Example : 'James is the greatest at kumite!' => 'MDPHV LV WKH JUHDWHVW DW NXPLWH!'
// Make sure to preserve the spaces and punctuation of the original message, you know, for clarity's sake.
const caesar = (shift, msg) => {
};
// 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.
const {expect} = require('chai');
describe('Caesar Function', () => {
it('should return the message with each letter of the alphabet shifted n times', () => {
let shift = 3;
let msg = 'James is the greatest at kumite!';
let exp = 'MDPHV LV WKH JUHDWHVW DW NXPLWH!'
const res = caesar(shift, msg);
expect(res).to.equal(exp);
});
it('should not eliminate spaces or punctuation', () => {
let shift = 13;
let msg = '! 3214 @!#$';
let exp = '! 3214 @!#$';
const res = caesar(shift, msg);
expect(res).to.equal(exp);
});
});