Skip to content

IndependentLowerJaw shows hints with relevant spaces trimmed #67697

@ethanwallace203

Description

@ethanwallace203

Describe the Issue

the test case is saying [pyramid("o", 4, false) should return "\n o\n ooo\n ooooo\nooooooo\n". ] but that is clearly not how the pyramid should be constructed that would return

 o
 ooo
 ooooo
ooooooo

and comply with the other positive testcase

Affected Page

https://www.freecodecamp.org/learn/javascript-v9/lab-pyramid-generator/lab-pyramid-generator

Your code

function pyramid(char, height, bool){
  let pyramid = []
  if(!bool){
    for(let i = 0; i < height; i++){
      pyramid.push(`\n${" ".repeat(height - 1 - i)}${char.repeat(1 + (2*i))}`)
    }
  } else {
    for(let i = 0; i < height; i++){
      pyramid.push(`\n${" ".repeat(height - (height - i))}${char.repeat(1 + (2*(height-(i + 1))))}`)
    }
  }  
  return pyramid.join("")
}

console.log(pyramid("o", 4, false))
console.log("\n o\n ooo\n ooooo\nooooooo\n")

Expected behavior

The correct test case should be [pyramid("o", 4, false) should return '\n o\n ooo\n ooooo\nooooooo'.] which would make the correctly formatted

   o
  ooo
 ooooo
ooooooo

Screenshots

No response

System

  • Device: Desktop
  • OS: windows 11
  • Browser: brave
  • Version: Brave | 1.90.128 Chromium: 148.0.7778.217 (Official Build) (64-bit)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform: learnUI side of the client application that needs familiarity with React, Gatsby etc.scope: UIThreads for addressing UX changes and improvements to user interfacestatus: discussingUnder discussion threads. Closed as stale after 60 days of inactivity.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions