#Typescript toThrow test

2 messages · Page 1 of 1 (latest)

empty hill
#

What does the test CODE RUN say? Can you share your complete code?

tender adder
#

`export function toRna(givenDna: string) {
let isValid = true;
let result = ""
let dnaArray = givenDna.toLowerCase().split('');

dnaArray.forEach((d) => {
if (!(d in dna)) {
throw new Error('Invalid input DNA.')
}
})

dnaArray.forEach((v) => {
if(v in dna) {
result += (dna[v as keyof Dna]).toUpperCase()
}
})

return result

}`