Having Problems Transitioning from Intro To 1st Codeacademy Kelvin project


#1

EDIT - Okay there are some other intro lessons linked to from this forum that were not provided from another link. Ill do those and check back

NEVER CODED BEFORE TONIGHT

The intro went pretty easily for me, but it seems like there are alot of missing links from that in order to code the Kelvin project.

Im having problems learning how the actual whiole entire complete code is supposed to look like.

It doesn’t seem like i can get the actual number assigned to the word to where it will do computation

The first step is
“The forecast today is 294 Kelvin. To start, create a variable named kelvin, and set it equal to 294. The value saved to kelvin will stay constant. Choose the variable type with this in mind.”

so with the only knowledge imparted to me from the intro, i coded

console.log('const kelvin = 294');

it printed
“const Kelvin = 294”

I know that’s wrong, because i couldn’t get that 294 assigned right to do the further computations.

So im pretty much stuck and can’t get past jump


#2

Did the step ask you to log anything to the console… or simply initialise a variable? You know it is constant but what type of data is it? A number… a string etc? Read over it again :slight_smile:


#3

Alright, no console - but it still didn’t compute

i had to write a comment explaining each line so my code looks like this. I had the last asterisk for the end quote - it just wont show up here in the comments

/*
kelvin equals 294
/
const kelvin = 294 ;
/

Celsius is 273 degrees less than Kelvin
*/
const celsius = kelvin - 273 ;

  1. the problem is that it didn’t compute , so is there some code I’m missing prior to the const kelvin / const celsius to compute the numbers ?

  2. where on the site do i go to that explains how to code to get that to compute ?


#4

Variable and constant declarations take place at the start of a program in a segment called initialization. It’s important that all declarations are made first so that their variables and values are defined when called up.

const kelvin = 294;

would be a sensible first line of this program. Knowing what kelvin temperature is means we can now find Celsius degrees given the conversion formula…

const celsius = kelvin - 273;

These statements do not output anything to the display. They are set in memory (RAM). To inspect a variable, log it out…

console.log(kelvin)     //    294
console.log(celsius)    //    21

#5

I think the comments in your code may be excluding your variable initializing as the format is everything between /* and */ is a multiline comment. Use // for single line comments. Try the below.

// kelvin equals 294
const kelvin = 294;

// verify kelvin is set to 294
console.log(kelvin);

// Celsius is 273 degrees less than Kelvin
const celsius = kelvin - 273;

// verify celsius is 21
console.log(celsius);


#6

peeps ! thanks much ! - it appears that it wound up calculating everything at the end - i was expecting it to do a running total each step and thought i was leaving something out - will study your codes - as they are logical and make sense - thanks again !


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.