Today is the Day explainer


#1

The aim of this puzzle: Create and print out the value of a new variable called day that stores the word 'Friday'.

Walkthrough of the solution: This puzzle starts out with two lines: var month = 'August' and print(month). The first line starts with var month which means: create a new variable and call it month. You can think of a variable like an empty container with a label on it. The label doesn’t change, but you can put whatever you want inside of the container. To put something inside of the container, you use =. In this case, the code is going to put the word 'August' inside of the month variable.

The second line uses a function called print(). This will take whatever you put in its parentheses and try to write text on the screen as a string. If you print a string, you will see just see the string. If you print a number, you’ll get the number. But if you print a variable, you will see the value stored inside that variable – not the name of the variable. That’s why print(month) writes 'August' to the screen, rather than month.

Your goal is to add to this code to create a variable called day that stores the word 'Friday', and prints that to the screen. You can almost copy the first two lines, changing the name of variable and the value it’s storing.

Sample code solution:
(Tap below to reveal)

var month = 'August';
print(month);
var day = 'Friday';
print(day);

JavaScript Concepts: Calling Functions, Identifiers, Variable Declaration
Grasshopper Concepts: print()


Can’t type in a Var
Can’t type in a Var
#4

Unable to declare variable as Friday.It doesn’t give options to type it


#5

@Manesh_M
You should see a button named str with a little picture of a keyboard next to it that let’s you type in a string. The solution code provided above is a bit wrong because it’s missing the ending for 'Friday and thus considers everything after 'Friday to be part of the string. It should work fine in the app though?


#6

Great!!! That worked :slight_smile:. Thanks for the help


#7

You’re welcome. Have a nice day :smile:


#8

I am entering the correct code and the output is also correct but it doesn’t shows the option to move on next topic what to do?


#9


I’m not sure what I’m doing wrong


#10

Hi @Ashwin_Anand,
What does your code look like? You may have the right output, but if the puzzle sees that you did an alternate solution without the new material, it won’t let you continue.


#11

Hi @zach_Bischof,
Looks like you renamed the variables to include uppercase letters and changed var Friday to var Day. In programming, it’s common practice to name variables with all lowercase letters, unless it’s multiple words. Then it’ll look something like: var theDayOfTheWeek. Granted, that’s a longer variable name then preferable, but it shows what I mean. If you reset the variable names back to the original names (Month -> month; Day -> friday) then you’ll have the right solution. :+1:


#12

Thanks @mysteryguy3039! You are totally right.

@zach_Bischof, this is an easy mistake to make and something we’re not providing good feedback for at the moment. So thanks for flagging it, I’m working on fixing this.

H :slight_smile:


#13

Am kinda lost here. Any help?


#14

Hi @Jd_Carl,
You have you’re variables set correctly, however, you’re printing the string instead of the variables. The strength of variables is being able to store a value for repeated use later. Instead of print(‘Friday’);, you can do print(Day); and because ‘Friday’ is stored in Day, Friday will be what is printed out.
It also looks like you renamed the original variable friday to Day which will cause an issue with being able to continue even if it’s technically correct.
Hope this helps :smile:


#15


#16

Hey @Tiago_nascimento,

That definitely looks like a bug; your code is correct.

If you hard-close the Grasshopper app, open it again, then run this code is the problem resolved?

Thanks for reporting and sorry you’ve hit up against this problem!
H :slight_smile:


#17

I have done as instructed and it seems correct, but how do I add a line at the end?


#18

You’ve written variable 'Day' during print as a string. Remove the str during print and your code will be fine.


#19

Successful! :+1: Thanks


#20


DONE BY RONY


#21

WOOT! thanks for the help


#22

Why the drawBoxes function is not getting the argument as made variable earlier.?