/    Sign up×
Community /Pin to ProfileBookmark

Hello, I have to do an exercise that I’m doing and we were asked to calculate the DNI through functions, so for the moment I know that type of calculator should follow me by giving you the code I have:
var dni = prompt (“Escriu el teu dni”)
function letraDNI(dni){
var cadena = [“T”, “R”, “W”, “A”, “G”, “M”, “Y”, “F”,”P”, “D”, “X”, “B”, “N”, “J”, “Z”, “S”, “Q”, “V”, “H”, “L”, “C”, “K”, “E”, “T”]
var poscion = dni%23;
var letra = cadena.substring(poscion,poscion+1);
return dni + ” – ” + letra;
}
document.write(letraDNI(dni));
If you could tell me how to continue thank you, a salute and I hope you’ll have a good day.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @panicornio spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...