+ 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

24th Mar 2018, 11:31 AM
Naeim Rahimzade
Naeim Rahimzade - avatar
10 Respuestas
+ 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
24th Mar 2018, 11:39 AM
jay
jay - avatar
+ 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
24th Mar 2018, 12:13 PM
Lord Krishna
Lord Krishna - avatar
+ 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
24th Mar 2018, 11:52 AM
Lord Krishna
Lord Krishna - avatar
+ 2
It displays Mr Smart when no name entered but OK clicked and Mr Anonymous when cancel button clicked!* *(Here)
24th Mar 2018, 12:17 PM
Naveen Maurya
Naveen Maurya - avatar
+ 2
@Raj Srivastava Y U DO DIS? 😂
24th Mar 2018, 1:19 PM
Naeim Rahimzade
Naeim Rahimzade - avatar
+ 1
@Jay I'd love to send the picture of my chrome saying Mr.null 😂😞
24th Mar 2018, 12:01 PM
Naeim Rahimzade
Naeim Rahimzade - avatar
+ 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
24th Mar 2018, 12:03 PM
Naeim Rahimzade
Naeim Rahimzade - avatar
+ 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
24th Mar 2018, 12:22 PM
Naeim Rahimzade
Naeim Rahimzade - avatar
+ 1
@Naveen Maurya You checked it with chrome?
24th Mar 2018, 12:22 PM
Naeim Rahimzade
Naeim Rahimzade - avatar
+ 1
I meant pc chrome guys,if it's ok
24th Mar 2018, 12:23 PM
Naeim Rahimzade
Naeim Rahimzade - avatar