Closed frankcollins3 closed 1 year ago
typeof === 'object' emailStr: @gmail.,gmail object
somehow the truthy block of this ternary operator runs splitEmail !== null || splitEmail !== undefined ? console.log(splitEmail[0]) : console.log('hey null!')
from browsertools:
emailStr: null object
// value said to be null which I knew since it's been null null null until [@ . ] characters meet match
splitEmail !== null || splitEmail !== undefined && splitEmail[0] ? console.log(splitEmail[0]) : console.log('hey null!')
kind of confused why doesn't work either it's asking if it exists and provides a case for what to do if it doesn't:
.log('hey null')
[5:24pm]
browser tools to show it's null. the above console.log() is not commented out to avoid compilation
splitEmail
SignupInput.tsx:77 null
SignupInput.tsx:78 emailStr: null | | | | | object
SignupInput.tsx:87 splitEmail
SignupInput.tsx:88 null
SignupInput.tsx:76 splitEmail
SignupInput.tsx:77 null
SignupInput.tsx:78 emailStr: null | | | | | object
SignupInput.tsx:87 splitEmail
SignupInput.tsx:88 null
SignupInput.tsx:76 splitEmail
SignupInput.tsx:77 null
SignupInput.tsx:78 emailStr: null | | | | | object
SignupInput.tsx:87 splitEmail
SignupInput.tsx:88 null
SignupInput.tsx:76 splitEmail
SignupInput.tsx:77 null
SignupInput.tsx:78 emailStr: null | | | | | object
SignupInput.tsx:87 splitEmail
SignupInput.tsx:88 null
SignupInput.tsx:76 splitEmail
SignupInput.tsx:77 null
SignupInput.tsx:78 emailStr: null | | | | | object
SignupInput.tsx:87 splitEmail
SignupInput.tsx:88 null
SignupInput.tsx:76 splitEmail
SignupInput.tsx:77 null
SignupInput.tsx:78 emailStr: null | | | | | object
SignupInput.tsx:87 splitEmail
SignupInput.tsx:88 null
SignupInput.tsx:76 splitEmail
SignupInput.tsx:77 null
SignupInput.tsx:78 emailStr: null | | | | | object
SignupInput.tsx:87 splitEmail
SignupInput.tsx:88 null
[5:25pm]
woooooooow chatGPT gave me this code:
if (splitEmail !== null) {
console.log('aaaye')
const matchedValue = splitEmail[0];
console.log(matchedValue); // Output: the matched email string
}
// splitEmail !== null || splitEmail !== undefined && splitEmail[0] ? console.log(splitEmail[0]) : console.log('hey null!') the ternary operator does the same exact thing ?
[5:28pm]
this seems to show the ratio of coding with chat is just as or nearly as important as coding without it 👍 10 min issue could've kept: [chasing_tail, spinning_tires]
match is included the characters I thought replaced. Have to escape them. this issue is solved [5:34pm]
let splitEmail:any = value.match(splitAtDot) console.log(
emailStr: ${splitEmail} ${typeof splitEmail} ${splitEmail.length}
)heres the code:
context from which expression is run. Already verified to work with hasNums regex for password constraints checker const regexDefaults: RegexDefaults = { RstringAfterPeriod: /^..(.)$/, RreturnLettersAthruZ: /[a-z]/g, RreturnNumbers: /[0-9]/g, RhasCaps: /[A-Z]/g, RhasNums: /[A-Z]/g, RnoWhiteSpace: /\s/g, MsplitAtDot: /@([^.])./,
McharAfterComma: /,(.)/ };
[5:17pm]