oscar4
January 29, 2021, 12:18pm
1
how can i get this to open live with visual studio code
function convertToRoman(num) {
function getNumeral(digit, lowStr, midStr, nextStr) {
switch (true) {
case digit <= 3:
return lowStr.repeat(digit);
case digit === 4:
return lowStr + midStr;
case digit <= 8: // digits 5-8
return midStr + lowStr.repeat(digit - 5);
default: // digit 9
return lowStr + nextStr
}
}
let str = ""
// Thousands
str += "M".repeat(Math.floor(num/1000));
num %= 1000;
// Hundreds
str += getNumeral(Math.floor(num/100), 'C', 'D', 'M')
num %= 100;
// Tens
str += getNumeral(Math.floor(num/10), 'X', 'L', 'C')
num %= 10;
// Ones
str += getNumeral(num, 'I', 'V', 'X')
return str;
}
convertToRoman(36);
Sky020
January 29, 2021, 12:21pm
2
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
oscar4
January 29, 2021, 12:23pm
3
does that make any differance ?
ilenia
January 29, 2021, 12:24pm
4
what do you mean with “open live”?
oscar4
January 29, 2021, 12:25pm
5
so people can use it run it basicly
oscar4
January 29, 2021, 12:25pm
6
visual studio code is a code editor
ilenia
January 29, 2021, 12:26pm
7
if you have nodejs you can run the js file with that from the command line
node <file_name>
ilenia
January 29, 2021, 12:28pm
9
you can execute js files from the terminal like that, is it what you want to do?
oscar4
January 29, 2021, 12:30pm
10
i just want the code to work but i dont know y it isnt
oscar4
January 29, 2021, 12:30pm
11
it just says something about not declaring the type of code
ilenia
January 29, 2021, 12:32pm
12
what are you doing?
also if you have an error you should give it verbatim
oscar4
January 29, 2021, 12:34pm
15
im just trying to make a roman numarul converter
ilenia
January 29, 2021, 12:35pm
18
the ideal technique to give an error word for word is to copy it and then paste it where you are asking questions about it
oscar4
January 29, 2021, 12:37pm
19
how do i code that
when do u learn it at fcc
ilenia
January 29, 2021, 12:38pm
20
copying and pasting is considered a prerequisite, and part of the basics of being able to use a computer, so it is not included in freeCodeCamp