File tree Expand file tree Collapse file tree
Week3/homework/Masoud/creditCardValidator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const validateCreditNumber = (creditCardNumber) => {
88 if ( creditCardNumber . length !== 16 ) {
99 return `Invalid! The input ${ creditCardNumber } should contains 16 characters!` ;
1010 } else {
11- return 'success!' ;
11+ return true ;
1212 }
1313 }
1414
@@ -27,7 +27,7 @@ const validateCreditNumber = (creditCardNumber) => {
2727 if ( index . length !== 0 ) {
2828 return `Invalid! The input ${ creditCardNumber } should contains only numbers!` ;
2929 } else {
30- return 'success!' ;
30+ return true ;
3131 }
3232
3333 }
@@ -46,14 +46,14 @@ const validateCreditNumber = (creditCardNumber) => {
4646 if ( index . length == 0 ) {
4747 return `Invalid! The input ${ creditCardNumber } should contains at least 2 different types of numbers!` ;
4848 } else {
49- return 'success!' ;
49+ return true ;
5050 }
5151 }
5252
5353 //The last number must be even
5454 function mustEven ( creditCardNumber ) {
5555 if ( creditCardNumber [ creditCardNumber . length - 1 ] % 2 == 0 ) {
56- return 'success!' ;
56+ return true ;
5757 } else {
5858 return `Invalid! The last number must be even` ;
5959 }
@@ -68,7 +68,7 @@ const validateCreditNumber = (creditCardNumber) => {
6868 if ( sum < 16 ) {
6969 return `Invalid! The input ${ creditCardNumber } should contains the numbers that must be greater than 16! `
7070 } else {
71- return 'success!' ;
71+ return true ;
7272 }
7373 }
7474
@@ -82,7 +82,7 @@ const validateCreditNumber = (creditCardNumber) => {
8282 array . push ( mustEven ( creditCardNumber ) ) ;
8383 array . push ( sumOf ( creditCardNumber ) ) ;
8484 for ( let i = 0 ; i < array . length ; i ++ ) {
85- if ( array [ i ] !== 'success!' ) {
85+ if ( array [ i ] !== true ) {
8686 console . log ( array [ i ] ) ;
8787 } else {
8888 array2 . push ( array [ i ] ) ;
You can’t perform that action at this time.
0 commit comments