0

Expected OutPut

Model = GT-N8000, cordova_version = 3.6.4, OS = Android

Hello I am trying to make one string as shown below But it is display the values not the name of values .I am not able to get attribute and = in a striing here is my code

var deviceInfo = ''

var deviceInfo = '';

deviceInfo += model = getModel() + ',';
deviceInfo += cordova_version = cordovaVersion() + ',';

deviceInfo += OS = getOS();

alert(deviceInfo);
function getModel() {
    return "GT-N8000"
}
function cordovaVersion() {
    return "3.6.4"
}
function getOS() {
    return "Android"
}

https://jsfiddle.net/nL7ouohv/

2 Answers 2

1

Try below code.

var deviceInfo = ''

var deviceInfo = '';

deviceInfo += 'Model = ' + getModel() + ',';
deviceInfo += 'cordova_version = ' + cordovaVersion() + ',';

deviceInfo += 'OS = ' + getOS() + ',';

alert(deviceInfo)

function getModel() {
    return "GT-N8000"
}

function cordovaVersion() {
    return "3.6.4"
}

function getOS() {
    return "Android"
}
Sign up to request clarification or add additional context in comments.

Comments

0

u are using variables as part of your string:

var myVar = "string"; alert(myVar); its the same of doing alert("string");but doing alert("myVar") will alert your var name as a string

so in your case:

deviceInfo = "MODEL = "+getModel()+", CORDOVA_VERSION = "+cordovaVersion()+", OS = "+getOS();

the fiddle

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.