title: Check if a string contains another string React Native
body: <p>I am trying to filter an array of data like so:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let data = 
  [
     {
      "approval": "TPED",
      "manufacturer": "Chesterfield"
     },
     {
      "approval": "BV",
      "manufacturer": "Faber"
     }
  ]
  
  let approvalVariable = "TP"
  let filteredData = data.filter(x =&gt; x.approval.includes(approvalVariable))
  
  console.log(filteredData)</code></pre>
  </div>
  </div>
  </p>
  
  <p>So if approvalVariable is "TP", I want the new array to be:</p>
  
  <pre><code>[
     {
      "approval": "TPED",
      "manufacturer": "Chesterfield"
     },
  ]
  </code></pre>
  
  <p>I have it working when I do:</p>
  
  <pre><code>let filteredData = data.filter(x =&gt; x.approval == approvalVariable)
  </code></pre>
  
  <p>But when I try:</p>
  
  <pre><code>x.approval.includes(approvalVariable)
  </code></pre>
  
  <p>I get an error that x.approval.includes is not an object </p>
  
  <p>I had it working at one point with .includes() but something is going wrong now.</p>
  
  <p>Any help would be greatly appreciated. </p>
  
  <pre><code>  componentWillMount() {
      this.fetchData();
    }
  
   fetchData = async () =&gt; {
     var fireBaseResponse = firebase.database().ref();
     fireBaseResponse.once('value').then(snapshot =&gt; {
       let data1 = [];
       let approval = this.props.navigation.state.params.approval
       let comments = this.props.navigation.state.params.comments
       let designStandard = this.props.navigation.state.params.designStandard
       let diameter = this.props.navigation.state.params.diameter
       let h2Compatible = this.props.navigation.state.params.h2compatible
       let inletThread = this.props.navigation.state.params.inletThread
       let manufacturer = this.props.navigation.state.params.manufacturer
       let specificationNumber = this.props.navigation.state.params.specificationNumber
       let testPressure = this.props.navigation.state.params.testPressure
       let waterCapacity = this.props.navigation.state.params.waterCapacity
       let workingPressure = this.props.navigation.state.params.workingPressure
  
  
      snapshot.forEach(item =&gt;{
          const temp = item.val();
          data1.push(temp);
          return false;
        });
  ////////Filter Method/////////
        if(approval == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.approval.includes(approval))
        }
        if(waterCapacity == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.waterCapacity == waterCapacity)
        }
        if(designStandard== '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.designStandard == designStandard)
        }
        if(diameter == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.diameter == diameter)
        }
        if(inletThread == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.inletThread == inletThread)
        }
        if(workingPressure == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.workingPressure == workingPressure)
        }
        if(comments == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.comments == comments)
        }
  
        if(manufacturer == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.manufacturer == manufacturer)
        }
        if(testPressure == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.testPressure == testPressure)
        }
  
        if(specificationNumber == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.specificationNumber == specificationNumber)
        }
        if(h2Compatible == '') {
          console.log("good")
        }
        else {
          data1 = data1.filter(x =&gt; x.h2Compatible == h2Compatible)
        }
  
  
  /////////////////////Filter Method//////////////////
  
        this.setState({data: data1});
  
      });
    }
    render(){
      var {navigate} = this.props.navigation;
      let {params} = this.props.navigation.state;
      return(
      &lt;ViewContainer&gt;
          &lt;ScrollView&gt;
           &lt;FlatList
                  data = {this.state.data}
                  keyExtractor = {(x, i) =&gt; i}
                  renderItem ={({item}) =&gt;
                      &lt;Text style = {styles.itemText}&gt;
                          Approval: {item.approval} | Manufacturer: {item.manufacturer} | Specification Number: {item.specificationNumber} |
                          H2 Compatible: {item.h2Compatible} | Diameter: {item.diameter} | Water Capacity: {item.waterCapacity} |
                          Inlet Thread: {item.inletThread}{"\n"}
                      &lt;/Text&gt;
                  }
              /&gt;
          &lt;/ScrollView&gt;
              &lt;View style ={styles.footer}&gt;
                  &lt;TouchableOpacity style ={styles.footerButton} onPress = { () =&gt; navigate("ValveSearchScreen")}&gt;
                      &lt;Text style ={styles.footerButtonText}&gt;SEARCH&lt;/Text&gt;
                  &lt;/TouchableOpacity&gt;
              &lt;/View&gt;
      &lt;/ViewContainer&gt;
  
      )
    }
  }
  </code></pre>