#i need help in js my code is not working right

38 messages · Page 1 of 1 (latest)

vital cipher
steep cedar
#

You're using assignment operator (=)

vital cipher
#

yes

steep cedar
#

You'd want to use a comparison operator (==)

#

In the if-statement

vital cipher
#

i got it in web3

#

ok

#

let me try that

steep cedar
#

if (day = 12) assigns day variable with the integer 12 as the value

#

It'll error for the day variable not existing after you do that change

vital cipher
#

bro could u pz tye the code

steep cedar
#
var age = 24;

if (day = 12) {
  console.log('good day');
}
#

What do you want the code to do?

#

The code there is just the code you had in your screenshot, I just copied it and got it into a codeblock

#

The code isn't doing what you want, but what would you want the code to do?

#

Don't know how to help you if I don't know what you'd want the code to do

vital cipher
#

im sorry for sking to much

steep cedar
#

I'll try my best to help you understand what you need to do, and what you need to learn to do what you want to do once I know what that is

vital cipher
#

so i just have to past it now

steep cedar
#

Hm?

#

I didn't fix anything

#

It's the code you had to begin with

#

What do you want the code to do?

vital cipher
#

ahhh thanlsk

#

i used ==

steep cedar
#

So the code is

var age = 24;

if (day == 12) {
  console.log('good day');
}

Or?

vital cipher
#

its woring

#

working

#

im soo new to this haha

steep cedar
#

Your code doesn't have a variable named day

#

So, what you have there won't ever print the good day

vital cipher
#

broooooo

steep cedar
#

What are you trying to do with the code?

vital cipher
#

why im havung a eoorr

steep cedar
#

else if

#

If you want to do multiple comparisons

vital cipher
#

it worked

#

thanks