Help with this JS function

I have this JS function in a layout page I’m using on a MVC website:

$(document).ready(function () {
  //Display the welcome ad
  if (@Globals.configSettings.DisplayWelcomeAd != false) {

And what is happening is that @Globals.configSettings.DisplayWelcomeAd is false. It’s going and checking, and returning false, yet it still runs the code block every time. Do you have any idea why it would be doing this??

According to your current code the SocialShareKit.init(); will run everytime because of where you have it after the if statement.

Or are you saying the WelcomeAd is displaying everytime too?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


Also, try to get in the habit of indenting your code to make it more readable. I cleaned up the indentation also.

Does changing to strict equality checking do anything different? (from != to !==). If you console.log @Globals.configSettings.DisplayWelcomeAd what do you get?