function isValidWalk(walk) {
//insert brilliant code here
return walk.length === 10 || walk.length === 0 ? true: false ? ;
}
? ;
question mark before the semicolon? Try to remove that and see if it changes anything?
Note: you will always receive a valid array containing a random assortment of direction letters ('n', 's', 'e', or 'w' only). It will never give you an empty array (that's not a walk, that's standing still!).
//some test cases for you...
Test.expect(isValidWalk(['n','s','n','s','n','s','n','s','n','s']), 'should return true');
Test.expect(!isValidWalk(['w','e','w','e','w','e','w','e','w','e','w','e']), 'should return false');
Test.expect(!isValidWalk(['w']), 'should return false');
Test.expect(!isValidWalk(['n','n','n','s','n','s','n','s','n','s']), 'should return false');
n
s is exactly same as number of s
s
e
s must be equal to number of w
s
n
s than s
s
dr-d-m sends brownie points to @khaduch and @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 237 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
:star2: 3711 | @khaduch |http://www.freecodecamp.org/khaduch
.reduce()
method, as well) but if you simply make four variables, use a case
statement to test the values and at the end if each of the counts is the same for the ones that should match, and your length is 10, you're good to go!
for
loop is straightforward and no need to add additional complications if you aren't yet familiar with .reduce()
... :)
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2375 | @darrenfj |http://www.freecodecamp.org/darrenfj
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2376 | @darrenfj |http://www.freecodecamp.org/darrenfj
$(document).ready(function() {
$('.rating-circle').hover(
function() {
$(this).prev().css('background-color', 'yellow')
}, function() {
$(this).css('background-color', '')
});
});
abyshukla sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8938 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
body {
font-family: Verdana;
}
h1, h2, h3 {
color: darkblue;
}
.rating-circle {
height: 2em;
width: 2em;
border: .1em solid black;
border-radius: 1.1em;
display: inline-block;
margin: 0;
padding: .1em;
}
.rating-hover {
background-color: yellow;
}
.rating-chosen {
background-color: green;
}
</style>
</head>
<body>
<h1>Contoso Web Developer Conference</h1>
<h2>Finding elements using jQuery</h2>
<div>This session is about identifying elements using jQuery methods and selectors.</div>
<h3>Rate this session</h3>
<div id="rating-container">
<div class="rating-circle"></div>
<div class="rating-circle"></div>
<div class="rating-circle"></div>
<div class="rating-circle"></div>
<div class="rating-circle"></div>
</div>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script>
</script>
prev()
prev()
, the div still changes color when i hover my mouse over it, the only problem is that my aim highlighting the previous div is then defeated.
<ol class="rating">
<li class="rating-circle" id="1"></a></li>
<li class="rating-circle" id="2"></a></li>
<li class="rating-circle" id="3"></a></li>
<li class="rating-circle" id="4"></a></li>
<li class="rating-circle" id="5"></a></li>
</ol>
.rating-circle {
height: 2em;
width: 2em;
border: .1em solid black;
border-radius: 1.1em;
display: inline-block;
margin: 0;
padding: .1em;
}
.addhover {
background: yellow;
}
$('ol.rating li').hover(function(){
var id = $(this).attr('id');
var counter = 1;
var salt = $(this).attr('class');
$('ol.rating li.'+salt).each(function(i){
if (id >= counter) {
$('li#'+counter).addClass("addhover");
} else {
$('li#'+counter).removeClass("addhover");
}
counter++;
});
}, function() {
$('li').removeClass("addhover");
});
jeffersonnnn sends brownie points to @blombergvictor :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @blombergvictor |http://www.freecodecamp.org/blombergvictor
ol.rating li
work
li
child of an ol
that has a class of rating
malbarmawi sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8939 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
<hr>
rule?
div {
border: dotted 1px black;
}
muhammedkarim sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8940 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
hr{
border-top: dotted 1px;
}
rehabthis sends brownie points to @leeconnelly12 :sparkles: :thumbsup: :sparkles:
:cookie: 190 | @leeconnelly12 |http://www.freecodecamp.org/leeconnelly12
rehabthis sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8941 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
etcigor sends brownie points to @harry9656 :sparkles: :thumbsup: :sparkles:
:cookie: 112 | @harry9656 |http://www.freecodecamp.org/harry9656
<button>Change the content of the p elements</button>
<p>This is a paragraph</p>
<p>This is another paragraph</p>
<script>
$(document).ready(function(){
$( "button" ).click(function() {
$('p').html("This p element has an index:1");
$('p').html("This p element has an index:2");
});
});
</script>
$('p')
will select all paragraphs
$('#p1')
to select the first one
nth-of-type
like $('p:nth-of-type(1)').html("This p element has an index:1");
$('p:nth-of-type(2)').html("This p element has an index:2");
darrenfj sends brownie points to @codernewby :sparkles: :thumbsup: :sparkles:
[words you want people to see](link here)
muhammedkarim sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2377 | @darrenfj |http://www.freecodecamp.org/darrenfj
kingwindie sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @njm8 |http://www.freecodecamp.org/njm8
kingwindie sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 432 | @ezioda004 |http://www.freecodecamp.org/ezioda004
hello guys I am getting data in my console, once props get updated but not able to print data on screen
ass MethodList extends Component{
componentDidMount(){
this.props.fetchMethod();
}
render(){
const methodList = this.props.state.methodList;
const tabledata = methodList.map((item,index)=> {
console.log('item is', item.name);
<Table.Row key={ index}>
<Table.Cell>{item.name} </Table.Cell>
<Table.Cell>{item.description}</Table.Cell>
<Table.Cell><Icon name="delete"/><Icon name="edit"/></Table.Cell>
</Table.Row>
})
return(
<div className="users">
<Topbar
heading = 'Methods'
description = 'Method of the Application'
as = '/app/methods/create'
path ='methodList?action=create'
buttonName = 'Add Method'
buttonIcon = 'add user'
/>
<SearchSection
options = {searbarInputs}
/>
<Table celled selectable>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Method Name</Table.HeaderCell>
<Table.HeaderCell>Description</Table.HeaderCell>
<Table.HeaderCell>Action</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{tabledata}
</Table.Body>
</Table>
</div>
)
}
}
d-flex justify-content-center
to your button class should work
mx-auto
div
class?
<head>
?
muhammedkarim sends brownie points to @mbosnjak01 :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @mbosnjak01 |http://www.freecodecamp.org/mbosnjak01
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
muhammedkarim sends brownie points to @mbosnjak01 :sparkles: :thumbsup: :sparkles: