Hello guys,
I have an interview tomorrow and it involves 10 minutes of code defense session. We were told told to code this https://codepen.io/samuelachema/pen/zJOgad which is an ARMSTRONG test of 3 digits number as part of the code challenge.
Does anyone have an idea on how the code defense session works? If you can, take a very good look at the code, what will you say needs to be improved?
Thanks.
if(number.length !== 3){
msg.innerHTML = "";
button.style.opacity = "0.5";
} else {
msg.innerHTML = "";
button.style.opacity = "1";
}
I wonder why they have msg.innerHTML = āā in both parts of the if statement? That suggests the line should not be there.
I would guess the ādefenseā is going to require you to understand exactly what each line of code does and why it is written in that way (versus another way).
Thanks for your time @hbar1st . msg.innerHTML = āā;
is to clear the message div any time there is an input length test.
I just googled an āarmstrong numberā. Definition: āA number a is an Armstrong Number or narcissistic number if it is equal to the sum of its own digits raised to the power of the number of digits. This definition is dependent on the base, b, used to represent the number.ā If you enter number 238, formulae for calculating would be (2^3)+(3^3)+(8^3). So if this sum is equal to number itself, then it is armstrong number. I guess you should also explain how your i/o works and why is styled that way. Answer for me would be that is easier for user to understand what is asked from him/her. If it is, then say it is, if itās not then say it is not armstrong number. Edit: Traditionally is done with three numbers. Why itās not generally applied by more then three numbers, i donāt know. It shouldnāt be to computationally intensive ā¦ Ps: thereās not two digit armstrong number or say post on interwebzās forums ā¦ Iām to lazy to calculate on paper ā¦
Also, I would suggest using a ternary operator here to set the opacity to reduce repeat code.
Very valuable input. Thanks
I have never had an interview that included something that I heard called a ācode defenseā. My guess is that they will have you go through your solution for them. They might ask why you chose to do things a certain way, why you didnāt choose to do something else, how efficient your solution is, how robust your solution is, etc. Despite the name, try hard not to get too defensive. If you see a weakness in your code, admit to it. Thatās a normal thing to have happen and part of why code reviews exist for developers.
My guess is that the rationale for this is to confirm that you wrote your own code and understand it (no StackOverflow copy-pasta), to see your thought process and the way you approach problems, and generally to get a sense of what it would be like to talk to you about your code. Remember that when a developer is interviewing you, what they are trying to figure out is āDo I want to work with this person?ā. You donāt need all the answers or to write perfect code, but you need to be smart, know enough that they donāt feel like they have to hold your hand, and be someone they want to collaborate with.
I wish I saw this earlier, not that I was that defensive in a bad way. I just got done with the interview. Hoping for the best. Thanks all
Hi @Devspert . I hope you got the job?
I didnāt get this one in particular but Iām happily engaged now.
1 Like