Bake a Cake explainer


The aim of this puzzle: Make a list (array) of ingredients (strings) needed to bake a cake.

Walkthrough of the solution: The cook() function is ready to turn ingredients into a cake but right now ingredients is just ‘flour’.

First, tap on the string ‘flour’ to highlight it. Next, tap the [] button to replace ‘flour’ with an empty array []. Now tap the str button to open the keyboard and type in the name of an ingredient like ‘sugar’ or ‘eggs’. Tap the empty space below the new ingredient you just entered and add another.

Once you have at least 2 strings inside the ingredients array, try running the code to bake your cake.

Sample code solution:
(Tap below to reveal)

var ingredients = [ 

JavaScript Concepts: Data Structures (arrays), Variable Declaration, Calling Functions, Identifiers

Bake a Cake explainer OLD

Did you just add this puzzle in late May? I went to look, and it was one which I hadn’t done. I also found a quiz I hadn’t done.


@Scott_McNay — Yup! We’re continually improving the courses, and sometimes that means replacing, or adding, new Puzzles or Quizzes.


Can i see the code running in the back? I’d there is any

const cook = array => {
  if (Array.isArray(array) && array.length > 1 && !array.includes('')) {
    print('You baked a cake!');
  } else {
    print("That's not enough ingredients.");

There’s quite a bit of code here that hasn’t been taught before the Bake a Cake puzzle. Basically, cook is a function, like pickRandom() or drawBox(). When you put an array inside of the parentheses of cook(), it checks 3 things:

  1. Is this really an array? It shouldn’t be just a number, or a string, or something else.
  2. Does the array have more than 1 item? It shouldn’t be empty or only have 1 item.
  3. Are any items in the array blank? There shouldn’t be any empty strings which is just quote marks without anything in between.

If the thing in the parentheses passes all 3 checks, then the message 'You baked a cake!' gets printed out. If it fails any of the tests, then it prints out 'That's not enough ingredients.'



This is a good game forr a kid like me it is challenging


Does not helping :sob::sob::sob::sob::sob::sob::sob::unamused::unamused::unamused::unamused::unamused::unamused::sob::unamused::sob::unamused::sob::unamused::sob::unamused::sob::sob:


If you post a screenshot of your code, I could take a look at what’s happening.



So basically you have to press or use the array function for each ingredient.


Each ingredient will be a separate string on its own line, surrounded with quote marks around each and with commas in between. And all the strings should be inside the array, between the square brackets [].