Skip to content

Commit f6b29cc

Browse files
committed
some condition changes
1 parent 7591809 commit f6b29cc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/_Classics_/caeser_cipher/caeserCipher.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
*/
55
function caesarCipher(toEncipher, shift = 0) {
66
// If required for very strict shift checking then remove '=0'
7-
if (typeof (Number(shift)) !== 'number') {
8-
return Error('Invalid Shift Provided')
7+
if (typeof (Number(shift)) !== 'number' && (shift !== NaN || shift !== 'NaN' || Number(shift) !== NaN )) {
8+
throw Error('Invalid Shift Provided')
99
} else {
1010
shift = Number(shift);
1111
}
1212

13-
if(typeof(toEncipher) === 'string' || typeof(toEncipher) === 'number') {
13+
if(typeof(toEncipher) === 'string' || (typeof(toEncipher) === 'number' && toEncipher !== NaN)) {
1414
toEncipher = String(toEncipher);
1515
} else {
16-
return Error('Invalid string provided');
16+
throw Error('Invalid string provided');
1717
}
1818

1919
// These are the valid entries aacepted, you can change it according to requirements

0 commit comments

Comments
 (0)