question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in Challenge: Use Multiple Conditional (Ternary) Operators.

See original GitHub issue

Describe your problem and how to reproduce it: Bug - Test for below code fails with error: checkSign should use multiple conditional operators.

function checkSign(num) {
  return (num!==0) ?(num>0) ? "positive" 
    : "negative" 
    : "zero";
}


console.log(checkSign(10));
console.log(checkSign(-10));
console.log(checkSign(0));

Screenshot -1: image

Screenshot - 2: image

How to reproduce It. Instead of Error: “checkSign should use multiple conditional operators.” Error should be: Using multiple ternary operators in statement-if-true part of ternary operator is not best practice.

(Increasing clarity of error message)

Add a Link to the page with the problem: Link to Challenge; Link to my post reporting bug on forum:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
ShaunSHamiltoncommented, May 23, 2020

“It’s is a best practice to format the multiple conditional operators so that each condition is on a separate line, as shown in the example, for readability.”

I would be for adding a note similar.

2reactions
jeremyltcommented, May 22, 2020

I agree that some tweaking makes sense. I’d would help if we can capture the fact that the test fails if a) you aren’t using a multiple ternary or b) the ternary isn’t in the expected format.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug in Challenge: Use Multiple Conditional (Ternary) Operators
I think the challenge fails to check for Ternary operators in statement-if-true part of Ternary operator. JeremyLT ...
Read more >
How to Use Multiple Conditional (Ternary) Operators in ...
By watching this video, you will learn how to use multiple conditional operators in JavaScript. Thank you so much for watching, ...
Read more >
Use Multiple Conditional Ternary Operators - YouTube
Free Code Camp Material - To help you learn and walk-through step-by-step.JavaScript Algorithms and Data Structures SectionBasic Javascript ...
Read more >
Im trying to understand the "Conditional (ternary) operator." Do ...
Im trying to understand the "Conditional (ternary) operator." Do these 2 codes mean the same thing? I wrote the if statement.
Read more >
Simple And Bug-Free Code With Dart Operators - Medium
The ternary operator already exists in most languages, but we'll discuss it here for a more complete flow. The ternary operator allows a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found