Javascript Coding Challenge #19: Roman Numeral Converter (Freecodecamp)
Vložit
- čas přidán 2. 07. 2024
- 🔥 Get my FREE project-based Javascript course, zeeee best Free Javascript course in the world, at www.whatsdev.com!
*FOLLOW ME!
►INSTAGRAM @zinnylives
►Business Only: tenzin@whatsdev.com
MY EQUIPMENT LINKS TO AMAZON
The mic I use to record my golden voice - amzn.to/2E3bAEq
The laptop I use to edit my LIT videos - amzn.to/2H00cwx
The keyboard I use to code - amzn.to/2GRnODr
The most ergonomic mouse that I use all the time - amzn.to/2NkVWIX
The best android phone on the market - amzn.to/2TWYbo9
The camera I use to shoot my awesome videos - amzn.to/2BKC7X2
My 4K mirrorless camera - amzn.to/2E31WBL
The best Gaming Desktop - amzn.to/2XgDea7
The best bang-for-buck 4K UHD IPS Monitor - amzn.to/2U0C7cx
The best 29" UltraWide Screen LED-Lit Monitor - amzn.to/2GVVoYI
The memory card I use - amzn.to/2TYawIQ
My High-Def PRO webcam - amzn.to/2U2jIMy
The best storage for my ever-growing collection - amzn.to/2NqV85z
The flash drive I use - amzn.to/2T82PCB
The best Digital Wireless Microphone - amzn.to/2E2YXJz
I feel like most people just don't have the patience to explain every little detail like this. So, thank you for taking the time to do it.
Thanks a lot for having the patience to explain in such great detail while having a cold!
"if it hurts your brain, that's a good sign, because that means you're learning something" amen. thanks for your high quality videos!
I got to say I really love how you actually take the time to explain the code in detail!!! This is by far the best tutorial on this challenge.
10+++ for explanation again, you have a huge gift for explanations dude ! thanks
Thanks Nicolae! I appreciate it 😃
Yes definitely
best explanation 10/10 I just got this karta today and now I understand this
Maan this explanation was awesome! The best one I've seen so far. Congrats and thank you!
Love the way how you walk us through the code! subscribed! Thanks a lot!
Bro this series of videos are gold, thank you so much!
The explanation and the code were a piece of art.
Oh my God thank you for the great explanation! I started to learn javascript a week ago, I'm given a assigments to make a function that converts digits into latters...was so lost but this video gave a hint and a better understanding of loops and function! Thank you again!!!
wow.... you are the best at explaining logic. Some people goes on and on for nothing.. I need to definitely join your course.
i really love your way of explaining the concepts.hatsoff !.For beginners its a key ...
THANK YOU SO MUCH. I had to watch this about 10 times but its so clear now
Thank you!!! I'm going to keep practicing. Great explanation!!
Damn!! It's PERFECT!! so simple, clear!! Please make more videos!
Amazing explanation
Thanks for all of your videos. They're really helping me understand every challenge in Free Code Camp!
Thanks a lot guy! this is a perfect and clear explanation
Best clear solution, simple and efficient
Detailed explanation.. Thank you so much
That's a great explanation. Thanks!
Beautifully and simply composed; excellent and clear explanation. Thank you!
hey dear, am linda and u? am from Nigeria? can i be your friend? sorry i saw ur comment on youtube channel, are you a developer?
i am glad i came across this....thanks alot !!!
Thanks a lot, bro. You save my day.
Wow, how easily you explaining thank you
I had to comment, thank you Tenzin, implementing your solution to my wagon!
I was talking your chanel lightly until I understood this great example by you, awesome explanation;👍
can you continue to make these videos? i am teaching myself every single one over and over until its ingrained my brain.
oh man that was so simple. i wrote almost 3 pages of code to do what your few lines of code does
same here hahah
You are an absolutely cool guy!!!!!
Very helpful, great explaination.
massive difference between watching someone do this.. and coming up with it yourself.. if you read this.. can you remember if when you were starting out.. something like this seems almost impossible to come up with on your own? im good at understanding things.. i just have trouble with creation sometimes. im in a code camp right now
ohhhhh! Mind blowing explanation brother , keep helping students u r doing such a great work stay bless and happy ,and make more videos like this and thank u for this
You are the best!
Awesome explanation man.... thanks (:
You did a great job
Thank you!
thank you so much !
i like the way you explain
@whatsdev Thanks for the awesome walk through! Can you elaborate on using a for in loop and whether the order of execution is predictable? I was under the impression that for in loops happen in arbitrary order.
Thank you 😊
think i need to buy jab-jab-javascript. you are a remarkable teacher and you make everything make sense. zero bullshit 100% results. i expect it will be the hardest thing i've ever done and i'm looking forward to it. let's GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!!!!!!!!!!!!!!!!!!!!!
Thanks bro❤️
sounds simple but why are the object keys have to be exactly in this pattern to beat the challenge?
M:1000,
CM:900,
D:500,
CD:400,
C:100,
XC:90,
L:50,
XL:40,
X:10,
IX:9,
V:5,
IV:4,
I:1
*good explanation*
That’s a nice solution. I used a massive switch statement to pass the test but this is a better option 😅
The order in which you defined your object is must otherwise if you shuffle the object value randomly then it never generate the original results eg:- shuffle the whole object in random order and then try for 1000
thanks great content! get better!
very helpful thanks dear
What do you think about creating a function that lets you put in lazy numbers e.g IIII, VIIII and regular numbers to convert to Roman numerals?
Feel better man!
NoahH Thanks man! Trying lol 😂
How did you come up with the values you inserted in your key-value pair?? They seem to be random roman numerals descending from 1000
Thank you for the video. What is the difference if the key-value starts from I:1 in romanToNum objects?
thank u sooooooooooo much
I am so sad , this beautiful series has no more videos..
Tanzan thanks for the challenges but this last of numerical i only saw stars........ may be i will keep revising and see if i can get it but i think i leaent alot from the challenges. thank man......buy you monster one day
Just tried with another roman numerals set and it doesn't work. Does it have to be the dataset you showed?
where is the guitar??
what about using hashmap to solve this challange ?
but what if we do num-9 then how will it print IX
1:24 That's what she said😂
tanks dude - brazil is watching y
Before watching this vid I came up with this. Is there any reason I should have gone the route the video maker went with? My algo beat the challenge but is there room for improvement?
function convertToRoman(num) {
function unit(x) {
switch(x) {
case 1: return 'I';
case 2: return 'II';
case 3: return 'III';
case 4: return 'IV';
case 5: return 'V';
case 6: return 'VI';
case 7: return 'VII';
case 8: return 'VIII';
case 9: return 'IX';
}}
function tens(x) {
switch(x) {
case 1: return 'X';
case 2: return 'XX';
case 3: return 'XXX';
case 4: return 'XL';
case 5: return 'L';
case 6: return 'LX';
case 7: return 'LXX';
case 8: return 'LXXX';
case 9: return 'XC';
}
}
function hun(x) {
switch(x) {
case 1: return 'C';
case 2: return 'CC';
case 3: return 'CCC';
case 4: return 'CD';
case 5: return 'D';
case 6: return 'DC';
case 7: return 'DCC';
case 8: return 'DCCC';
case 9: return 'CM';
}}
function thou(x) {
switch(x) {
case 1: return 'M';
case 2: return 'MM';
case 3: return 'MMM';
case 4: return 'MMMM';
}
}
let arr = String(num).split("")
let arr2 = []
for (let i=0;i
Would be interesting to come up with a solution without the mapping object
cool
dumb ass
I just can't get how can someone still unlike that
nice
Does the order of roman numerals(descending), stored in the romanToNum object, matter?
Yes, because the for in loop will only move in one direction, so the order the roman numerals need to be in must match the way the arabic numerals convert to roman numerals.
Haha just like FunFunFunction. If your brain hurts, it's a good thing -- It means you're learning! Seriously though, thanks for creating this video for us. You explained everything very well!
make more videos brother
Here is a simpler solution with single for loop
function convertToRoman(num) {
var roman = {
M: 1000,
CM: 900,
D: 500,
CD: 400,
C: 100,
XC: 90,
L: 50,
XL: 40,
X: 10,
IX: 9,
V: 5,
IV: 4,
I: 1
};
var romanNum = "";
for(key in roman){
var check = num>=roman[key];
if(check){
console.log(romanNum);
romanNum += key;
num-= roman[key];
}
}
return romanNum
}
convertToRoman(150);
i watched all the tutorials but find really hard to solve any problem and need to see the solution in internet. Do other people also experience this, or just me?
noted. drink cold water when having cold, with that I can be a developer like him .
Please I run this same code in repl.it, but it gives me 'undefined', why?
function convertToRoman(num){
var romanToNum = {
M:1000,
CM: 900,
D: 500,
CD: 400,
C: 100,
XC: 90,
L: 50,
XL: 40,
X: 10,
IX: 9,
V: 5,
IV: 4,
I: 1
};
var roman = "";
for(var key in romanToNum){
console.log(key);
}
}
Did you call your function?
1:24 thats what she said
hi i dont know you will read tthis comments or not. anyway. I used your code as solution but it is saying wrong answer
I still have problems with roman numerals.
Hoow do you know that XC is not just 10+100, but 100-10?
Why CC is 100+1000, and not 100-100.
Superb explanation. Kind of distracting though not gonna like I feel like I always need to take some benzodiazepines after watching your videos.
"hard and long" lol
worst challengs in the world ! 😂😂😂 ! the problem is not js .. its the problem 😑
Thank you!