2017-09-27 62 views
-5
var $scope.data = [ 
{ 
    id: 1, 
    name: "Akash" 
}, 
{ 
    id: 2, 
    name: "Vipul" 
}, 
{ 
    id: 3, 
    name: "Mahesh" 
}]; 
var character = [];  
_.filter($scope.data, function (item) { 
    character.push(item.id); 
}); 
console.log("Character::", character); 

輸出::字符:: [ 「1」, 「2」, 「3」]顯示陣列看起來像下面

欲輸出像:

您字符是1, 2,和3

+1

顯示您爲此嘗試的代碼。 – Ved

+4

先生,我想你忘了提交我們的提交日期。請提一下,然後我們會做你的任務。 –

回答

0

var arr = [ "C", "c", "b", "B", "A" ]; 
 
var text =""; 
 
arr.forEach(function(val,index){ 
 
    if(index <= arr.length-2){ 
 
    text = text + val +"," 
 
    }else{ 
 
    text = text +" and " +val 
 
    } 
 

 
    
 
}) 
 
console.log("Your characters are",text)

1

請檢查下面

char [] data = { 'C', 'c', 'b', 'B', 'A' }; 
string joinString = string.Join(", ", data); 

string result = string.Format("your character is {0}", joinString.Insert(joinString.LastIndexOf(",")+1, " and"));