Ifycode-support / Danbaba1-exercism-issues

0 stars 1 forks source link

Issue with Amusement park function 3 #6

Open Danbaba1 opened 2 years ago

Danbaba1 commented 2 years ago

Exercise: Amusement park

Function: 3

Issue: My code is not working

export function ticketStatus(tickets, ticketId) {
  if(!tickets.ticketId){
    return ('unknown ticket id');
  } else if(tickets.ticketId == null){
    return ('not sold');
  } else if(tickets.ticketId){
    return ('sold to {name}');
  }
}
Ifycode commented 2 years ago

@Danbaba1 You are not completely following how I said you should go about creating issues and pull requests. It's usually easier to review using a PR than with issues. So when you create an issue, always create a PR that goes with it (a new file with the code as content of the file). Then link the PR to the issue. It's that simple.

You can see I also had to change your issue title. Please use Ideas from this so I can easily differentiate the issues. Also, tag me.

Ifycode commented 2 years ago

It looks like you don't understand why I'm doing it this way, so I will explain some things to you. You would apply for some tech job or scholarship etc. And some would request your Github profile. some others want to see your GitHub activities for the last 6 months etc. A not-so-active GitHub profile is not to your advantage in those cases. The things you have on your GitHub profile don't need to be for a job or a gig. The ones you do while learning too are also allowed. It shows proof of your constant learning.

So while the goal is not to fill up your Github profile, it will be to your advantage that your profile shows/reflects your learning process. If it goes ahead to showcase you're able to use git/github, it's even better. I will stop here for now.

Ifycode commented 2 years ago

As for the issue you are having with this code @Danbaba1 :

What you should do:

Danbaba1 commented 2 years ago

@Ifycode thank you ma for helping out.

Danbaba1 commented 2 years ago

@Ifycode


function ticketStatus(tickets, ticketId) {
  if(ticketId in tickets.keys()){
    if(ticketId === null){
      return 'not sold';
    } else {
      return 'sold to ' + tickets.ticketId;
    }
  }
  return 'unknown ticket id';
}

it still did not work.

Danbaba1 commented 2 years ago

@Ifycode

function ticketStatus(tickets, ticketId) {
  if(Object.keys(tickets).includes(ticketId)){
    if(tickets[ticketId] === null){
      return 'not sold';
    } else {
      return `sold to ${tickets[ticketId]}` ;
    }
  }
  return 'unknown ticket id';
}

it worked.

Ifycode commented 2 years ago

About the first one where you didif(ticketId in tickets.keys()), it will not work because if statement only works for setting a condition. It has nothing to do with the loop-like syntax you gave it to work with. I'm guessing you thought you could manipulate it like a for... in loop.

Ifycode commented 2 years ago

Nice... Now that you have a working answer... let me give you small work 😂 @Danbaba1 Nesting if or if else statements can be confusing for the reader sometimes. Even for you who wrote it. Work on the function ticketStatus(tickets, ticketId) function again. But this time, no nesting.

Danbaba1 commented 2 years ago

@Ifycode okay ma I actually worked on the code yesterday because I really wanted it to work and it worked.