Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: function is not a function [duplicate]

Below I have the simplest code. In my name function its all good, it works but in the User_age function I get the following error:

User_age is not a function.

What am I doing wrong?

User_age();

function User_age()
{
    var age = promt("what is your age");
    var printAge = "your age is" + age;
    console.log(printAge);
}
name();

function name(){

    var username = prompt("what is your name");
    var greed = "hello" + username;
    console.log(greed);
}
like image 917
davidLaid Avatar asked May 16 '26 15:05

davidLaid


1 Answers

you have a small issue in your first function you are typing promt not prompt

 User_age();

function User_age()
{
var age = prompt("what is your age");
var printAge = "your age is" + age;
console.log(printAge);
}

name();

function name(){

var username = prompt("what is your name");
var greed = "hello" + username;
console.log(greed);
}
like image 127
Wassim Ben Hssen Avatar answered May 19 '26 04:05

Wassim Ben Hssen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!