If Cookie = X, then do something

Uhm i need help, how do i check if a cookie value is the same as the “X” variable value? When i tried to code that, it just sets the cookie to the X variable value.

Are you using = or ==?

1 Like

One equal sign, was i supposed to use 2?
I’m stupid.

Oh, i just tried it out, and it works! Thanks so much :slight_smile:

I’ll leave this cheatsheet for you:

// One equal sign means you want to set a variable
var x = 10

// Two equal signs means "equal to"
x == 10 // true
x == "10" // true

// Three equal signs means "equal value and equal type"
x === 10 // true
x === "10" // false

// one exclamation mark plus an equal sign means "not equal to"
x != 5 // true

// one exclamation mark plus two equal signs means "not equal value or not equal type"
x !== 10 // false
x !== "10" // true
x !== 8 // true
4 Likes