Transcription explainer


#1

The aim of this puzzle: Print out each letter, but change the T’s to U’s

Walkthrough of the solution: The for...of loop will store each letter of 'GATTACA' in element. Before the element is printed, we need to check if the letter is a 'T'. If it is, then we should switch the letter to a 'U' first. Inside the curly brackets of the If Statement, add element = 'U'.

Sample code solution:
(Tap below to reveal)

var sequence = 'GATTACA';
for (var element of sequence) {
  if (element === 'T') {
    element = 'U';
  }
  print(element);
}

JavaScript Concepts: Code Block (if statement), Calling Functions, Identifiers, Loops, Conditionals (if statement), Variable Declaration

Grasshopper Concepts: print()


#3

Man I’m doing it right but it is saying otherwise! WTHHH


#4

Could you post a screenshot of your code?

–Frankie


#5

Why do we use ===
in the if (element === ‘T’)

But only =
In element = ‘U’
?


#6

=== checks if 2 things are equal
= makes the variable on the left side equal to the right side


element === 'T'Check if the element is currently equal to 'T'

element = 'U'Set the value of element to 'U'

–Frankie


#7


B
R
O
K
E
N
?


#8

Try using a capital 'U' instead of lowercase 'u'.

–Frankie


#9


#10

Hey there,

The 1st time a variable is used, we declare it with the var keyword. After it’s declared, however, we can just refer to it by its name. var is used for new variables only.

Try changing var element = 'U' to just element = 'U', and that should solve the problem.

Hope this helps!
Ben