Skip to content

A workaround that bypasses challenge's limitation of not using endsWith() function. #12198

@tnmygrwl

Description

@tnmygrwl

Challenge Name

Confirm the Ending

Issue Description

Detailed Description:
FreeCodeCamp requires the camper to not use .endsWith() function to solve the given Basic Algorithm Scripting challenge in any way:

This challenge can be solved with the .endsWith() method, which was introduced in ES2015. But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead.

However, a simple workaround can bypass this given test:

Do not use the built-in method .endsWith() to solve the challenge.

Workaround: Using if and else conditions to return true or false if the condition of str.endsWith(target) is satisfied.

Browser Information

  • Browser Name, Version: Google Chrome Canary, 57.0.2960.0
  • Operating System: OS X El Capitan (Version: 10.11.6)
  • Mobile, Desktop, or Tablet: Macbook Pro 13' Retina (Early 2015)

Your Code

 function confirmEnding(str, target) {

  // #BUG: A workaround to bypass the limitation of not being able to use built-in function `.endsWith()`
  
  if (str.endsWith(target)) {
    return true;
  } else {
    return false;
  }
}

confirmEnding("Bastian", "n");

 
 

^This code passes the challenge and uses the built-in method .endsWith(). If the code doesn't work, please click on Reset button and paste it again.

Screenshot

screen shot 2016-12-24 at 1 14 47 pm

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: shippingTo be applied to issues or PR's that are already fixed or resolved and are awaiting deployment

    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