Unable to compare a string with array

时间:2017-08-30 20:09:50

标签: javascript

I have tried different solutions and am unable to figure out why I can't compare a string with an array string.

Here is what I have tried:

structure(list(specific_value = c(1, 1, 1, 2, 3, 2, 1, 5), name = c("Luke", 
"Luke", "Skywalker", "Leia", "Han", "Organa", "Ben", "Lando"), 
    surname = c("Skywalker", "Skywalker", "Luke", "Organa", "Solo", 
    "Leia", "Solo", "Calrissian"), random_value = c(1, 2, 3, 
    4, 5, 6, 7, 8)), class = "data.frame", .Names = c("specific_value", 
"name", "surname", "random_value"), row.names = c(NA, -8L))

I am unable to get to "someone has won" as the condition is never true however when printing the values out in console both are the same values i.e. public async Task<ServiceResult<Config>> GetConfigAsync(string id) { var entity = await _entityRepo.FindAsync(t => t.Id == id); if (entity == null) throw new Exception($"entity Id {id} is invalid"); var result = JsonConvert.DeserializeObject<Config>(entity.Config); return new ServiceResult<Config>(result); } and var configTask = _configurationService.GetConfigAsync(id); var config = configTask.GetAwaiter().GetResult(); .

Any support is most welcome.

2 个答案:

答案 0 :(得分:3)

It's a typo. Your array is the list of elements

  • "h,"
  • "e,"
  • "l,"
  • "l"
  • "o"

The first three elements have commas as part of the string.

The correct code would be:

[s]

Change

margin: auto;

to

use FacebookAds\Object\AdCreative;
use FacebookAds\Object\AdCreativeLinkData;
use FacebookAds\Object\Fields\AdCreativeLinkDataFields;
use FacebookAds\Object\AdCreativeObjectStorySpec;
use FacebookAds\Object\Fields\AdCreativeObjectStorySpecFields;
use FacebookAds\Object\Fields\AdCreativeFields;

$link_data = new AdCreativeLinkData();
$link_data->setData(array(
  AdCreativeLinkDataFields::MESSAGE => 'try it out',
  AdCreativeLinkDataFields::LINK => '<URL>',
  AdCreativeLinkDataFields::IMAGE_HASH => '<IMAGE_HASH>',
));

$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
  AdCreativeObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
  AdCreativeObjectStorySpecFields::LINK_DATA => $link_data,
));

$creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>');

$creative->setData(array(
  AdCreativeFields::NAME => 'Sample Creative',
  AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));

$creative->create();

to fix it.

答案 1 :(得分:0)

我已经通过&#34; Array.match()&#34;解决了我的问题。基本上如果找不到匹配,它将返回一个&#39; null&#39;当它找到匹配时,它将显示匹配词。

这是我对这个难题的解决方案

function checkWin(){

            var a = emptyword.join("");
            var b = computerword;
            var c=  b.match(a);

          // for debug purpose only    
         console.log("match word so far...:"+ c);

    if(c != null)
        {
            console.log("match win");
            // clear the previous information 
            document.getElementById("correctguess").innerHTML =" ";

            document.getElementById("correctguess").innerHTML ="You have Won well done";

        }
        // for debug purpose only 
        console.log("emptyword is:"+ a);
        console.log("computerword is: "+ b);


}//  end CheckWin