1
Guys I need a help, I’m doing some exercises and I stuck in 3 specific on string, it’s simple but I’ve tried everything and I can’t find the mistakes.
Ex 1: Create a function perimeter that tells us the perimeter of a circle when we give it the radius as parameter. Also the function area which gives us the area of a circle when it receives the radius as parameter.
function perimetro(raio) {
var perimetro = π * raio * 2;
return perimetro;
}
function area(raio) {
var area = π * raio * raio;
return area;
}
\\Retorna dizendo que as variáveis locais são desnecessárias e que poderia retornar a expressão diretamente.
Ex 2: Create a function called sizeNomeComplete, which takes a name and a surname as parameters, and which will return the full size, counting an extra space to separate both.
function tamanhoNomeCompleto(nome, sobrenome) {
var NomeCompleto = (nome.lenght + sobrenome.length);
var tamanhoNomeCompleto = 6;
return tamanhoNomeCompleto;
}
Ex 3: Create a function write Letter, which takes as parameters a title, a name and a surname and returns a single string as a result.
function escreverCartao() {
var titulo = "Dra";
var nome = "Ana";
var sobrenome = "Pérez";
var escreverCartao = (titulo + " " + nome + " " + sobrenome);
return titulo + " " + nome + " " + sobrenome
And as for the variable
π
in the first?– Woss
Thanks for the help with the exercises, in 1 and 3 worked correctly your solution but in 2 still presents error "Nan == 10" I used a random number
– Nataly de Lima
I believe you might be using
nome.lenght
instead ofnome.length
, as you used in the question example– Rafael Januário