+ 4
Chrome's null Bug
Chrome has a bug,I was testing prompt in JavaScript in it,and put if and if else and else in it,which if the prompt was empty which means null,it calls hello anonymous and so on,but instead it says hello null,and the rest of my another if which was else and last if statement.check the code with chrome,Thanks A Lot! https://code.sololearn.com/WV6uigRTKOK2/?ref=app
10 Réponses
+ 13
I checked with chrome and it operates as expected.
No input and OK pressed, Mr smart
Input and OK pressed, Mr <input>
Cancel pressed, Mr anonymous
+ 5
What do you actually want to do here?
It returns 'mr.null' only if you enter null in the prompt & that's your default condition when no input is matched.
If you add another else if to check for literal null string it can alert a different text message. If that's what you want to do.
https://code.sololearn.com/WxkJ38t2H9no/?ref=app
+ 3
The behaviour is same on firefox. It's not a bug that's the expected output.
when you cancel the prompt, return value is null. When it's pressed ok without a value it's empty string.
# Read below for info about prompt.
https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt
+ 2
It displays Mr Smart when no name entered but OK clicked and Mr Anonymous when cancel button clicked!*
*(Here)
+ 2
@Raj Srivastava Y U DO DIS? 😂
+ 1
@Jay I'd love to send the picture of my chrome saying Mr.null 😂😞
+ 1
@Lord Krishna it works fine with the empty one and pressing Ok,cuz it gives the answer I want,problem is,chrome seems like not knowing what null is, or not wanting to receive it,what I'm looking for is an alternative for null in Chrome
+ 1
@Lord Krishna I'm not looking for The Null,I'm Saying what should I put instead of null Because this version of chrome I'm using doesn't accept null as the code,playground is fine with it,IE too,but only chrome has problem with it
+ 1
@Naveen Maurya You checked it with chrome?
+ 1
I meant pc chrome guys,if it's ok