File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
src/_Classics_/caeser_cipher Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 4
4
*/
5
5
function caesarCipher ( toEncipher , shift = 0 ) {
6
6
// 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' )
9
9
} else {
10
10
shift = Number ( shift ) ;
11
11
}
12
12
13
- if ( typeof ( toEncipher ) === 'string' || typeof ( toEncipher ) === 'number' ) {
13
+ if ( typeof ( toEncipher ) === 'string' || ( typeof ( toEncipher ) === 'number' && toEncipher !== NaN ) ) {
14
14
toEncipher = String ( toEncipher ) ;
15
15
} else {
16
- return Error ( 'Invalid string provided' ) ;
16
+ throw Error ( 'Invalid string provided' ) ;
17
17
}
18
18
19
19
// These are the valid entries aacepted, you can change it according to requirements
You can’t perform that action at this time.
0 commit comments